<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是uboot相关命令的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV05-01-uboot-03-uboot相关命令">
<meta property="og:url" content="https://sumumm.github.io/post/d56430c4.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是uboot相关命令的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-03-uboot%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4/img/image-20221013095607018.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-03-uboot%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4/img/image-20221013193827596.png">
<meta property="article:published_time" content="2023-09-08T11:22:54.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.040Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="(ALPHA)LV05-uboot与内核">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-03-uboot%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4/img/image-20221013095607018.png">


<link rel="canonical" href="https://sumumm.github.io/post/d56430c4.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/d56430c4.html","path":"post/d56430c4.html","title":"LV05-01-uboot-03-uboot相关命令"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV05-01-uboot-03-uboot相关命令 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%87%A0%E4%B8%AA%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="nav-text">一、几个常用命令</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-help"><span class="nav-text">1. help </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E6%9F%A5%E7%9C%8B%E6%89%80%E6%9C%89%E6%94%AF%E6%8C%81%E7%9A%84%E5%91%BD%E4%BB%A4"><span class="nav-text">1.1 查看所有支持的命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E6%9F%A5%E7%9C%8B%E6%8C%87%E5%AE%9A%E5%91%BD%E4%BB%A4%E5%B8%AE%E5%8A%A9%E4%BF%A1%E6%81%AF"><span class="nav-text">1.2 查看指定命令帮助信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.3 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-reset"><span class="nav-text">2. reset</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">2.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">2.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-loadb"><span class="nav-text">3. loadb</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">3.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">3.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-go"><span class="nav-text">4. go</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">4.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">4.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-run"><span class="nav-text">5. run</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#5-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">5.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">5.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-mtest"><span class="nav-text">6. mtest</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E4%BF%A1%E6%81%AF%E6%9F%A5%E8%AF%A2"><span class="nav-text">二、信息查询</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-printenv"><span class="nav-text">1. printenv </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.2 使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-1-%E6%9F%A5%E7%9C%8B%E6%89%80%E6%9C%89%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1.2.1 查看所有环境变量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-2-%E6%9F%A5%E7%9C%8B%E6%8C%87%E5%AE%9A%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1.2.2 查看指定环境变量</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-bdinfo"><span class="nav-text">2. bdinfo</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">2.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-1"><span class="nav-text">2.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-version"><span class="nav-text">3. version </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">3.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-1"><span class="nav-text">3.2 使用实例</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">三、环境变量</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-setenv"><span class="nav-text">1. setenv</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">1.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-1"><span class="nav-text">1.2 使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-1-%E4%BF%AE%E6%94%B9%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1.2.1 修改环境变量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-2-%E5%88%9B%E5%BB%BA%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1.2.2 创建环境变量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-3-%E5%88%A0%E9%99%A4%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1.2.3 删除环境变量</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-saveenv"><span class="nav-text">2. saveenv</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-2"><span class="nav-text">2.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BF%9D%E5%AD%98%E5%88%B0%E4%BA%86%E5%93%AA%E9%87%8C%EF%BC%9F"><span class="nav-text">2.2 保存到了哪里？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">2.3 使用实例</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E5%86%85%E5%AD%98%E6%93%8D%E4%BD%9C"><span class="nav-text">四、内存操作</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-md"><span class="nav-text">1. md</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-2"><span class="nav-text">1.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-2"><span class="nav-text">1.2 使用实例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-b%E3%80%81w%E3%80%81l"><span class="nav-text">1.3 b、w、l</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-nm"><span class="nav-text">2. nm</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-3"><span class="nav-text">2.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-2"><span class="nav-text">2.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-mm"><span class="nav-text">3. mm</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-2"><span class="nav-text">3.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-2"><span class="nav-text">3.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-mw"><span class="nav-text">4. mw</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">4.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-1"><span class="nav-text">4.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-cp"><span class="nav-text">5. cp</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#5-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">5.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-1"><span class="nav-text">5.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-cmp"><span class="nav-text">6. cmp</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">6.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">6.2 使用实例</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81%E5%AD%98%E5%82%A8%E5%99%A8%E8%AE%BF%E9%97%AE"><span class="nav-text">五、存储器访问</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-mmc-info"><span class="nav-text">1. mmc info</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-3"><span class="nav-text">1.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-3"><span class="nav-text">1.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-mmc-rescan"><span class="nav-text">2. mmc rescan</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-mmc-list"><span class="nav-text">3. mmc list</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-3"><span class="nav-text">3.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-3"><span class="nav-text">3.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-mmc-dev"><span class="nav-text">4. mmc dev</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-2"><span class="nav-text">4.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-2"><span class="nav-text">4.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-mmc-part"><span class="nav-text">5. mmc part</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#5-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-2"><span class="nav-text">5.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-2"><span class="nav-text">5.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-mmc-read"><span class="nav-text">6. mmc read</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">6.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-1"><span class="nav-text">6.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-mmc-write"><span class="nav-text">7. mmc write</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#7-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">7.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">7.2 使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#7-2-1-%E6%9B%B4%E6%96%B0SD%E5%8D%A1%E4%B8%AD%E7%9A%84uboot"><span class="nav-text">7.2.1 更新SD卡中的uboot</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-2-2-%E6%9B%B4%E6%96%B0EMMC%E4%B8%ADuboot"><span class="nav-text">7.2.2 更新EMMC中uboot</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8-mmc-erase"><span class="nav-text">8. mmc erase</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AD%E3%80%81%E7%BD%91%E7%BB%9C%E6%93%8D%E4%BD%9C"><span class="nav-text">六、网络操作</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%BD%91%E7%BB%9C%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1. 网络环境变量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-ping"><span class="nav-text">2. ping</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-4"><span class="nav-text">2.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-3"><span class="nav-text">2.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-dhcp"><span class="nav-text">3. dhcp</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-tftp"><span class="nav-text">4. tftp</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-3"><span class="nav-text">4.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-3"><span class="nav-text">4.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-nfs"><span class="nav-text">5. nfs</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#5-1-%E5%91%BD%E4%BB%A4%E7%AE%80%E4%BB%8B"><span class="nav-text">5.1 命令简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-2-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">5.2 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-3-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">5.3 使用实例</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%83%E3%80%81%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%93%8D%E4%BD%9C"><span class="nav-text">七、文件系统操作</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-FAT-%E6%A0%BC%E5%BC%8F%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">1. FAT 格式文件系统</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-fatinfo"><span class="nav-text">1.1 fatinfo</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-1-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.1.1 使用格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-1-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.1.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-fatls"><span class="nav-text">1.2 fatls</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.2.1 使用格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.2.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-fstype"><span class="nav-text">1.3 fstype   </span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-3-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.3.1 使用格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.3.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-4-fatload"><span class="nav-text">1.4 fatload</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-4-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.4.1 使用格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-4-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.4.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-5-fatwrite"><span class="nav-text">1.5 fatwrite  </span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-5-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.5.1 使用格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-5-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.5.2 使用实例</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-EXT-%E6%A0%BC%E5%BC%8F%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">2. EXT 格式文件系统</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AB%E3%80%81boot-%E6%93%8D%E4%BD%9C"><span class="nav-text">八、boot 操作</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%B8%A4%E4%B8%AA%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">1.两个环境变量</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-boodcmd"><span class="nav-text">1.1 boodcmd </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-bootargs"><span class="nav-text">1.2 bootargs </span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-bootz"><span class="nav-text">2. bootz</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-5"><span class="nav-text">2.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-4"><span class="nav-text">2.2 使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-1-%E9%80%9A%E8%BF%87%E7%BD%91%E7%BB%9C%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6"><span class="nav-text">2.2.1 通过网络下载文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-2-%E9%80%9A%E8%BF%87EMMC%E5%90%AF%E5%8A%A8"><span class="nav-text">2.2.2 通过EMMC启动</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-bootm"><span class="nav-text">3. bootm </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-4"><span class="nav-text">3.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-4"><span class="nav-text">3.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-boot"><span class="nav-text">4. boot</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-4"><span class="nav-text">4.1 使用格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B-4"><span class="nav-text">4.2 使用实例</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/d56430c4.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV05-01-uboot-03-uboot相关命令 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV05-01-uboot-03-uboot相关命令
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-09-08 19:22:54" itemprop="dateCreated datePublished" datetime="2023-09-08T19:22:54+08:00">2023-09-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/" itemprop="url" rel="index"><span itemprop="name">02IMX6ULL平台</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/" itemprop="url" rel="index"><span itemprop="name">LV05-uboot与内核</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>14k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>52 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是uboot相关命令的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-03-uboot%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows版本</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu版本</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>      </tr>    <tr>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="5">官方网站</td>        <td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td>        <td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/" target="_blank">https://www.nxp.com.cn/ </a></td>        <td align="left">NXP官方网站</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxpic.org.cn/" target="_blank">https://www.nxpic.org.cn/</a></td><td align="left">NXP 官方社区</td>    </tr>    <tr>        <td align="left"><a href="https://u-boot.readthedocs.io/en/latest/" target="_blank">https://u-boot.readthedocs.io/en/latest/</a></td><td align="left">u-boot官网</td>    </tr>    <tr>        <td align="left"><a href="https://www.kernel.org/" target="_blank">https://www.kernel.org/</a></td><td align="left">linux内核官网</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="4">NXP</td>        <td align="left"><a href="https://github.com/nxp-imx" target="_blank">https://github.com/nxp-imx</a></td>        <td align="left">NXP imx开发资源GitHub组织，里边会有u-boot和linux内核的仓库</td>    </tr>    <tr>        <td align="left"><a href="https://elixir.bootlin.com/linux/latest/source" target="_blank">https://elixir.bootlin.com/linux/latest/source</a></td>        <td align="left">在线阅读linux kernel源码</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP linux内核仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP u-boot仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="center" rowspan="2">I.MX6ULL</td>        <td align="left"><a href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLIEC.pdf" target="_blank">i.MX 6ULL Applications Processors for Industrial Products</a></td>        <td align="left">I.MX6ULL 芯片手册（datasheet，可以在线查看）</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/webapp/Download?colCode=IMX6ULLRM&lang_cd=zh" target="_blank">i.MX 6ULL Applications ProcessorReference Manual</a></td>        <td align="left">I.MX6ULL 参考手册（下载后才能查看，需要登录NXP官网）</td>    </tr></table>
              </div>
            </details>

<p>这里使用的是NXP厂商提供的u-boot，u-boot的命令是可以自己定义和裁剪的。</p>
<h1 id="一、几个常用命令"><a href="#一、几个常用命令" class="headerlink" title="一、几个常用命令"></a><font size=3>一、几个常用命令</font></h1><h2 id="1-help"><a href="#1-help" class="headerlink" title="1. help "></a><font size=3>1. help </font></h2><h3 id="1-1-查看所有支持的命令"><a href="#1-1-查看所有支持的命令" class="headerlink" title="1.1 查看所有支持的命令"></a><font size=3>1.1 查看所有支持的命令</font></h3><p>我们在 SecureCRT 终端输入 help ，便会打印出当前 uboot 所支持的所有命令。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-03-uboot%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4/img/image-20221013095607018.png" alt="image-20221013095607018" style="zoom:50%;" />

<details class="folding-tag" blue><summary> 点击查看相关命令 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br></pre></td><td class="code"><pre><span class="line">?       - alias for &#x27;help&#x27;</span><br><span class="line">base    - print or set address offset</span><br><span class="line">bdinfo  - print Board Info structure</span><br><span class="line">bmode   - sd1|sd2|qspi1|normal|usb|sata|ecspi1:0|ecspi1:1|ecspi1:2|ecspi1:3|esdhc1|esdhc2|esdhc3|esdhc4 [noreset]</span><br><span class="line">bmp     - manipulate BMP image data</span><br><span class="line">boot    - boot default, i.e., run &#x27;bootcmd&#x27;</span><br><span class="line">bootd   - boot default, i.e., run &#x27;bootcmd&#x27;</span><br><span class="line">bootelf - Boot from an ELF image in memory</span><br><span class="line">bootm   - boot application image from memory</span><br><span class="line">bootp   - boot image via network using BOOTP/TFTP protocol</span><br><span class="line">bootvx  - Boot vxWorks from an ELF image</span><br><span class="line">bootz   - boot Linux zImage image from memory</span><br><span class="line">clocks  - display clocks</span><br><span class="line">clrlogo - fill the boot logo area with black</span><br><span class="line">cmp     - memory compare</span><br><span class="line">coninfo - print console devices and information</span><br><span class="line">cp      - memory copy</span><br><span class="line">crc32   - checksum calculation</span><br><span class="line">dcache  - enable or disable data cache</span><br><span class="line">dhcp    - boot image via network using DHCP/TFTP protocol</span><br><span class="line">dm      - Driver model low level access</span><br><span class="line">echo    - echo args to console</span><br><span class="line">editenv - edit environment variable</span><br><span class="line">env     - environment handling commands</span><br><span class="line">erase   - erase FLASH memory</span><br><span class="line">exit    - exit script</span><br><span class="line">ext2load- load binary file from a Ext2 filesystem</span><br><span class="line">ext2ls  - list files in a directory (default /)</span><br><span class="line">ext4load- load binary file from a Ext4 filesystem</span><br><span class="line">ext4ls  - list files in a directory (default /)</span><br><span class="line">ext4size- determine a file&#x27;s size</span><br><span class="line">ext4write- create a file in the root directory</span><br><span class="line">false   - do nothing, unsuccessfully</span><br><span class="line">fatinfo - print information about filesystem</span><br><span class="line">fatload - load binary file from a dos filesystem</span><br><span class="line">fatls   - list files in a directory (default /)</span><br><span class="line">fatsize - determine a file&#x27;s size</span><br><span class="line">fdt     - flattened device tree utility commands</span><br><span class="line">flinfo  - print FLASH memory information</span><br><span class="line">fstype  - Look up a filesystem type</span><br><span class="line">fuse    - Fuse sub-system</span><br><span class="line">go      - start application at address &#x27;addr&#x27;</span><br><span class="line">gpio    - query and control gpio pins</span><br><span class="line">help    - print command description/usage</span><br><span class="line">i2c     - I2C sub-system</span><br><span class="line">icache  - enable or disable instruction cache</span><br><span class="line">iminfo  - print header information for application image</span><br><span class="line">imxtract- extract a part of a multi-image</span><br><span class="line">itest   - return true/false on integer compare</span><br><span class="line">load    - load binary file from a filesystem</span><br><span class="line">loadb   - load binary file over serial line (kermit mode)</span><br><span class="line">loads   - load S-Record file over serial line</span><br><span class="line">loadx   - load binary file over serial line (xmodem mode)</span><br><span class="line">loady   - load binary file over serial line (ymodem mode)</span><br><span class="line">loop    - infinite loop on address range</span><br><span class="line">ls      - list files in a directory (default /)</span><br><span class="line">md      - memory display</span><br><span class="line">mdio    - MDIO utility commands</span><br><span class="line">mii     - MII utility commands</span><br><span class="line">mm      - memory modify (auto-incrementing address)</span><br><span class="line">mmc     - MMC sub system</span><br><span class="line">mmcinfo - display MMC info</span><br><span class="line">mtest   - simple RAM read/write test</span><br><span class="line">mw      - memory write (fill)</span><br><span class="line">nfs     - boot image via network using NFS protocol</span><br><span class="line">nm      - memory modify (constant address)</span><br><span class="line">ping    - send ICMP ECHO_REQUEST to network host</span><br><span class="line">pmic    - PMIC</span><br><span class="line">printenv- print environment variables</span><br><span class="line">protect - enable or disable FLASH write protection</span><br><span class="line">reset   - Perform RESET of the CPU</span><br><span class="line">run     - run commands in an environment variable</span><br><span class="line">save    - save file to a filesystem</span><br><span class="line">saveenv - save environment variables to persistent storage</span><br><span class="line">setenv  - set environment variables</span><br><span class="line">setexpr - set environment variable as the result of eval expression</span><br><span class="line">sf      - SPI flash sub-system</span><br><span class="line">showvar - print local hushshell variables</span><br><span class="line">size    - determine a file&#x27;s size</span><br><span class="line">sleep   - delay execution for some time</span><br><span class="line">source  - run script from memory</span><br><span class="line">test    - minimal test like /bin/sh</span><br><span class="line">tftpboot- boot image via network using TFTP protocol</span><br><span class="line">true    - do nothing, successfully</span><br><span class="line">usb     - USB sub-system</span><br><span class="line">usbboot - boot from USB device</span><br><span class="line">version - print monitor, compiler and linker version</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="1-2-查看指定命令帮助信息"><a href="#1-2-查看指定命令帮助信息" class="headerlink" title="1.2 查看指定命令帮助信息"></a><font size=3>1.2 查看指定命令帮助信息</font></h3><p>我们输入 help（或 ? ）命令名 就可以查看指定命令的详细用法 ，即</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">? cmd_name</span><br><span class="line">help cmd_name</span><br></pre></td></tr></table></figure>

<h3 id="1-3-使用实例"><a href="#1-3-使用实例" class="headerlink" title="1.3 使用实例"></a><font size=3>1.3 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看实例 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">=&gt; help bootz</span><br><span class="line">bootz - boot Linux zImage image from memory</span><br><span class="line"></span><br><span class="line">Usage:</span><br><span class="line">bootz [addr [initrd[:size]] [fdt]]</span><br><span class="line">    - boot Linux zImage stored in memory</span><br><span class="line">        The argument &#x27;initrd&#x27; is optional and specifies the address</span><br><span class="line">        of the initrd in memory. The optional argument &#x27;:size&#x27; allows</span><br><span class="line">        specifying the size of RAW initrd.</span><br><span class="line">        When booting a Linux kernel which requires a flat device-tree</span><br><span class="line">        a third argument is required which is the address of the</span><br><span class="line">        device-tree blob. To boot that kernel without an initrd image,</span><br><span class="line">        use a &#x27;-&#x27; for the second argument. If you do not pass a third</span><br><span class="line">        a bd_info struct will be passed instead</span><br><span class="line"></span><br><span class="line">=&gt; ? bootz</span><br><span class="line">bootz - boot Linux zImage image from memory</span><br><span class="line"></span><br><span class="line">Usage:</span><br><span class="line">bootz [addr [initrd[:size]] [fdt]]</span><br><span class="line">    - boot Linux zImage stored in memory</span><br><span class="line">        The argument &#x27;initrd&#x27; is optional and specifies the address</span><br><span class="line">        of the initrd in memory. The optional argument &#x27;:size&#x27; allows</span><br><span class="line">        specifying the size of RAW initrd.</span><br><span class="line">        When booting a Linux kernel which requires a flat device-tree</span><br><span class="line">        a third argument is required which is the address of the</span><br><span class="line">        device-tree blob. To boot that kernel without an initrd image,</span><br><span class="line">        use a &#x27;-&#x27; for the second argument. If you do not pass a third</span><br><span class="line">        a bd_info struct will be passed instead</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="2-reset"><a href="#2-reset" class="headerlink" title="2. reset"></a><font size=3>2. reset</font></h2><h3 id="2-1-使用格式"><a href="#2-1-使用格式" class="headerlink" title="2.1 使用格式"></a><font size=3>2.1 使用格式</font></h3><p> reset 命令可以用于重启开发板，我们直接在命令行输入 reset 即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">reset   </span><br></pre></td></tr></table></figure>

<h3 id="2-2-使用实例"><a href="#2-2-使用实例" class="headerlink" title="2.2 使用实例"></a><font size=3>2.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看实例 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">=&gt; reset</span><br><span class="line">resetting ...</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="3-loadb"><a href="#3-loadb" class="headerlink" title="3. loadb"></a><font size=3>3. loadb</font></h2><h3 id="3-1-使用格式"><a href="#3-1-使用格式" class="headerlink" title="3.1 使用格式"></a><font size=3>3.1 使用格式</font></h3><p> loadb 命令通过串口进行数据的传输，我们一般使用该命令进行二进制文件的传输，它使用的是 kermit protocol 传输协议，一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">loadb [ off ] [ baud ]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>off ：其实就是数据要加载到内存中的起始地址。</li>
<li>baud ：传输的波特率，可以不写，默认为 115200 。</li>
</ul>
<p><strong>【注意】</strong>我们要是使用此种方式传输裸机程序的话，需要将裸机可执行文件 xxx.bin下载到开发板 DRAM 的 0X87800000 地址处，因为裸机可执行程序的链接首地址就0x87800000，当然，我们也可以修改裸机工程中的链接文件，修改链接地址，这里与链接地址一致即可。  </p>
<h3 id="3-2-使用实例"><a href="#3-2-使用实例" class="headerlink" title="3.2 使用实例"></a><font size=3>3.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">=&gt; loadb 87800000  </span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># Ready for binary (kermit) download to 0x80800000 at 115200 bps...</span></span></span><br></pre></td></tr></table></figure><p>然后按下 enter 按键便会等待数据的传输，我们可以直接将文件拖拽到 SecureCRT 终端界面中，然后选择发送 Kermmit 即可开启文件传输，将会有以下提示：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">  kermit  trl+C ȡ</span><br><span class="line">正在传输 device.h...</span><br><span class="line"><span class="meta prompt_">  100% </span><span class="language-bash">     41 KB      10 KB/  00:00:04       0</span>   </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># Total Size      = 0x0000a77d = 42877 Bytes</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># Start Addr      = 0x80800000</span></span></span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="4-go"><a href="#4-go" class="headerlink" title="4. go"></a><font size=3>4. go</font></h2><h3 id="4-1-使用格式"><a href="#4-1-使用格式" class="headerlink" title="4.1 使用格式"></a><font size=3>4.1 使用格式</font></h3><p> go 命令用于跳到指定的地址处执行应用，命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">go addr [arg ...]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>addr ：是应用在 DRAM 中的首地址。</li>
</ul>
<h3 id="4-2-使用实例"><a href="#4-2-使用实例" class="headerlink" title="4.2 使用实例"></a><font size=3>4.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">=&gt; tftp 87800000 /imx6ull/lcd.bin</span><br><span class="line">FEC1 Waiting for PHY auto negotiation to complete... done</span><br><span class="line">Using FEC1 device</span><br><span class="line">TFTP from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/imx6ull/lcd.bin&#x27;.</span><br><span class="line">Load address: 0x87800000</span><br><span class="line">Loading: ###</span><br><span class="line">         6.8 KiB/s</span><br><span class="line">done</span><br><span class="line">Bytes transferred = 35953 (8c71 hex)</span><br><span class="line"></span><br><span class="line">=&gt; go 87800000</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># Starting application at 0x87800000 ...</span></span></span><br><span class="line">LCD ID=0x4384</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="5-run"><a href="#5-run" class="headerlink" title="5. run"></a><font size=3>5. run</font></h2><h3 id="5-1-使用格式"><a href="#5-1-使用格式" class="headerlink" title="5.1 使用格式"></a><font size=3>5.1 使用格式</font></h3><p> run 命令用于运行环境变量中定义的命令，比如可以通过 run bootcmd 来运行  bootcmd 中的启动命令，但是 run 命令最大的作用在于运行我们自定义的环境变量。</p>
<p>在后面调试 Linux 系统的时候可能常常要在网络启动和 EMMC&#x2F;NAND 启动之间来回切换，而 bootcmd 只能保存一种启动方式，如果要换另外一种启动方式的话就得重写 bootcmd ，会很麻烦。这里我们就可以通过自定义环境变量来实现不同的启动方式，比如定义环境变量 mybootemmc 表示从 emmc 启动，定义 mybootnet 表示从网络启动，定义 mybootnand 表示从 NAND 启动。如果要切换启动方式的话只需要运行 run mybootxxx ( xxx 为  emmc 、  net 或  nand )即可。一般命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">run var [...]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>var ：表示需要运行的定义了命令的环境变量名。</li>
</ul>
<h3 id="5-2-使用实例"><a href="#5-2-使用实例" class="headerlink" title="5.2 使用实例"></a><font size=3>5.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">=&gt; setenv bootcmd &#x27;tftp 80800000 /imx6ull/zImage\;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb\;bootz 80800000 - 83000000&#x27;</span><br><span class="line">=&gt; printenv bootcmd</span><br><span class="line">bootcmd=tftp 80800000 /imx6ull/zImage;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb;bootz 80800000 - 83000000</span><br><span class="line">=&gt; saveenv    </span><br><span class="line">Saving Environment to MMC...</span><br><span class="line">Writing to MMC(0)... done</span><br><span class="line">=&gt; run bootcmd</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="6-mtest"><a href="#6-mtest" class="headerlink" title="6. mtest"></a><font size=3>6. mtest</font></h2><p> mtest 命令是一个简单的内存读写测试命令，可以用来测试自己开发板上的 DDR ，一般命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mtest [start [end [pattern [iterations]]]]</span><br></pre></td></tr></table></figure>

<ul>
<li>start ：要测试的 DRAM 开始地址。</li>
<li>end ：是结束地址。</li>
</ul>
<p>【注意】如果要结束测试就按下键盘上的 Ctrl + C 键。</p>
<h1 id="二、信息查询"><a href="#二、信息查询" class="headerlink" title="二、信息查询"></a><font size=3>二、信息查询</font></h1><p>常用的和信息查询有关的命令有 3 个： printenv、bdinfo 和 version。  </p>
<h2 id="1-printenv"><a href="#1-printenv" class="headerlink" title="1. printenv "></a><font size=3>1. printenv </font></h2><h3 id="1-1-使用格式"><a href="#1-1-使用格式" class="headerlink" title="1.1 使用格式"></a><font size=3>1.1 使用格式</font></h3><p>该命令主要用于打印出所有的环境变量信息，我们在 SecureCRT 终端中直接执行下边的命令，便可以得到该命令的使用格式：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">=&gt; ? printenv</span><br><span class="line">printenv - print environment variables</span><br><span class="line"></span><br><span class="line">Usage:</span><br><span class="line">printenv [-a]</span><br><span class="line">    - print [all] values of all environment variables</span><br><span class="line">printenv name ...</span><br><span class="line">    - print value of environment variable &#x27;name&#x27;</span><br></pre></td></tr></table></figure>

<p>该命令使用方式很简单，我们直接在命令行输入下边的命令即可。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">printenv [env_name]</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">或者</span></span><br><span class="line">print [env_name]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>env_name ：环境变量名，它是可选的，若要查看所有环境变量，省略该参数即可。</li>
</ul>
<h3 id="1-2-使用实例"><a href="#1-2-使用实例" class="headerlink" title="1.2 使用实例"></a><font size=3>1.2 使用实例</font></h3><h4 id="1-2-1-查看所有环境变量"><a href="#1-2-1-查看所有环境变量" class="headerlink" title="1.2.1 查看所有环境变量"></a><font size=3>1.2.1 查看所有环境变量</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">=&gt; print</span><br><span class="line">baudrate=115200</span><br><span class="line">board_name=EVK</span><br><span class="line">board_rev=14X14</span><br><span class="line">boot_fdt=try</span><br><span class="line">bootargs=console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.10.101:/home/hk/4nfs/imx_rootfs,proto=tcp rw ip=192.168.10.102:192.168.10.101:192.168.10.1:255.255.255.0::eth0:off</span><br><span class="line">bootcmd=tftp 80800000 /imx6ull/zImage;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb;bootz 80800000 - 83000000</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">中间部分省略 ... ...</span></span><br><span class="line">script=boot.scr</span><br><span class="line">serverip=192.168.10.101</span><br><span class="line"></span><br><span class="line">Environment size: 2673/8188 bytes</span><br></pre></td></tr></table></figure>
              </div>
            </details>



<h4 id="1-2-2-查看指定环境变量"><a href="#1-2-2-查看指定环境变量" class="headerlink" title="1.2.2 查看指定环境变量"></a><font size=3>1.2.2 查看指定环境变量</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">=&gt; print bootcmd</span><br><span class="line">bootcmd=tftp 80800000 /imx6ull/zImage;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb;bootz 80800000 - 83000000</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="2-bdinfo"><a href="#2-bdinfo" class="headerlink" title="2. bdinfo"></a><font size=3>2. bdinfo</font></h2><h3 id="2-1-使用格式-1"><a href="#2-1-使用格式-1" class="headerlink" title="2.1 使用格式"></a><font size=3>2.1 使用格式</font></h3><p> bdinfo 命令，此命令用于查看板子信息，直接在命令行输入该命令即可，一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bdinfo</span><br></pre></td></tr></table></figure>

<p>通过该命令，我们可以看到 DRAM 的起始地址和大小、启动参数保存起始地址、波特率、sp(堆栈指针)起始地址等信息。  </p>
<h3 id="2-2-使用实例-1"><a href="#2-2-使用实例-1" class="headerlink" title="2.2 使用实例"></a><font size=3>2.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">=&gt; bdinfo</span><br><span class="line">arch_number = 0x00000000</span><br><span class="line">boot_params = 0x80000100</span><br><span class="line">DRAM bank   = 0x00000000</span><br><span class="line"><span class="meta prompt_">-&gt; </span><span class="language-bash">start    = 0x80000000</span></span><br><span class="line"><span class="meta prompt_">-&gt; </span><span class="language-bash">size     = 0x20000000</span></span><br><span class="line">eth0name    = FEC1</span><br><span class="line">ethaddr     = b8:ae:1d:01:00:00</span><br><span class="line">current eth = FEC1</span><br><span class="line">ip_addr     = 192.168.10.102</span><br><span class="line">baudrate    = 115200 bps</span><br><span class="line">TLB addr    = 0x9FFF0000</span><br><span class="line">relocaddr   = 0x9FF47000</span><br><span class="line">reloc off   = 0x18747000</span><br><span class="line">irq_sp      = 0x9EF44EA0</span><br><span class="line">sp start    = 0x9EF44E90</span><br><span class="line">FB base     = 0x00000000</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="3-version"><a href="#3-version" class="headerlink" title="3. version "></a><font size=3>3. version </font></h2><h3 id="3-1-使用格式-1"><a href="#3-1-使用格式-1" class="headerlink" title="3.1 使用格式"></a><font size=3>3.1 使用格式</font></h3><p> version 用于查看  uboot 的版本号，直接输入 version 即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">version</span><br></pre></td></tr></table></figure>

<h3 id="3-2-使用实例-1"><a href="#3-2-使用实例-1" class="headerlink" title="3.2 使用实例"></a><font size=3>3.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; version </span><br><span class="line"></span><br><span class="line">U-Boot 2016.03-g9e33bde-dirty (Sep 25 2022 - 21:24:46 +0800)</span><br><span class="line">arm-linux-gnueabihf-gcc (Linaro GCC 4.9-2017.01) 4.9.4</span><br><span class="line">GNU ld (Linaro_Binutils-2017.01) 2.24.0.20141017 Linaro 2014_11-3-git</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h1 id="三、环境变量"><a href="#三、环境变量" class="headerlink" title="三、环境变量"></a><font size=3>三、环境变量</font></h1><p>上边我们通过 printenv 打印出来的信息中有很多的环境变量，比如  baudrate 、  bootcmd 等等。  uboot  中的<strong>环境变量都是字符串</strong>，既然叫做环境变量，那么它的作用就和变量一样。比如  bootdelay  这个环境变量就表示  uboot  启动延时时间，默认  bootdelay&#x3D;3 ，也就默认延时  3  秒。前面说的  3  秒倒计时就是由  bootdelay  定 义的，如果将  bootdelay  改为  5  的话就会倒计时  5s 了。</p>
<h2 id="1-setenv"><a href="#1-setenv" class="headerlink" title="1. setenv"></a><font size=3>1. setenv</font></h2><h3 id="1-1-使用格式-1"><a href="#1-1-使用格式-1" class="headerlink" title="1.1 使用格式"></a><font size=3>1.1 使用格式</font></h3><p>该命令主要用于操作环境变量，我们在 SecureCRT 终端中查看一下该命令使用格式：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">=&gt; ? setenv</span><br><span class="line">setenv - set environment variables</span><br><span class="line"></span><br><span class="line">Usage:</span><br><span class="line">setenv [-f] name value ...</span><br><span class="line">    - [forcibly] set environment variable &#x27;name&#x27; to &#x27;value ...&#x27;</span><br><span class="line">setenv [-f] name</span><br><span class="line">    - [forcibly] delete environment variable &#x27;name&#x27;</span><br></pre></td></tr></table></figure>

<p>该命令可以用于创建、修改、删除环境变量，一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">setenv env_name env_value</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>env_name ：表示要修改的环境变量名称。</li>
<li>env_value ： 表示环境变量的值，此参数省略的话可以用于删除相应的环境变量。</li>
</ul>
<p><strong>【注意】</strong></p>
<p>（1）此命令修改完后，开发板若重启，那么所有环境变量将会复原。</p>
<p>（2）有时候我们修改的环境变量值可能会有空格， 比如 bootcmd、 bootargs 等， 这个时候环境变量值就得用单引号括起来（后便会介绍这两个环境变量）。</p>
<h3 id="1-2-使用实例-1"><a href="#1-2-使用实例-1" class="headerlink" title="1.2 使用实例"></a><font size=3>1.2 使用实例</font></h3><h4 id="1-2-1-修改环境变量"><a href="#1-2-1-修改环境变量" class="headerlink" title="1.2.1 修改环境变量"></a><font size=3>1.2.1 修改环境变量</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们想修改一下 uboot 启动 linux 倒计时，这个时间是由 bootdelay 环境变量来控制的，我们上边是 5 秒，我们可以通过以下命令更改秒数</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; printenv bootdelay </span><br><span class="line">bootdelay=3</span><br><span class="line">=&gt; setenv bootdelay 5</span><br><span class="line">=&gt; printenv bootdelay </span><br><span class="line">bootdelay=5</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h4 id="1-2-2-创建环境变量"><a href="#1-2-2-创建环境变量" class="headerlink" title="1.2.2 创建环境变量"></a><font size=3>1.2.2 创建环境变量</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; printenv aaa</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># Error: &quot;aaa&quot; not defined</span></span></span><br><span class="line">=&gt; setenv aaa 1234567890</span><br><span class="line">=&gt; printenv aaa         </span><br><span class="line">aaa=1234567890</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h4 id="1-2-3-删除环境变量"><a href="#1-2-3-删除环境变量" class="headerlink" title="1.2.3 删除环境变量"></a><font size=3>1.2.3 删除环境变量</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们创建了不想要的环境变量怎么办呢？有创建肯定有删除，该命令同样也可以删除环境变量，去掉后边的值，就可以将一个已经存在的环境变量删除：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; printenv aaa</span><br><span class="line">aaa=1234567890</span><br><span class="line">=&gt; setenv aaa           </span><br><span class="line">=&gt; printenv aaa</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># Error: &quot;aaa&quot; not defined</span></span></span><br></pre></td></tr></table></figure><p>删除后，我们打印一个不存在测环境变量便会出错。</p>
              </div>
            </details>

<h2 id="2-saveenv"><a href="#2-saveenv" class="headerlink" title="2. saveenv"></a><font size=3>2. saveenv</font></h2><h3 id="2-1-使用格式-2"><a href="#2-1-使用格式-2" class="headerlink" title="2.1 使用格式"></a><font size=3>2.1 使用格式</font></h3><p>前边的环境变量我们修改后，只在此次使用有效，当开发板关机时，修改过的环境变量全部会失效，那如何保存下来，让这些修改过的环境变量后边也依然可以生效呢？我们可以使用 saveenv 命令，我们直接在终端输入命令即可，一般格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">saveenv</span><br></pre></td></tr></table></figure>

<h3 id="2-2-保存到了哪里？"><a href="#2-2-保存到了哪里？" class="headerlink" title="2.2 保存到了哪里？"></a><font size=3>2.2 保存到了哪里？</font></h3><p>我们使用这个命令后，环境变量被保存到哪里了呢？这个应该是在uboot源码中进行了定义，我没有去追踪，但是后来在一些资料中了解到，开发板若是<strong>从SD卡启动就保存到SD卡，EMMC启动就保存到EMMC</strong>，从后边学习mmc read命令的时候，可以看到环境变量存储的起始地址是从相应的mmc的0x600开始的。</p>
<h3 id="2-3-使用实例"><a href="#2-3-使用实例" class="headerlink" title="2.3 使用实例"></a><font size=3>2.3 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; saveenv </span><br><span class="line">Saving Environment to MMC...</span><br><span class="line">Writing to MMC(0)... done</span><br></pre></td></tr></table></figure><p>这样我们修改过的环境变量就会被保存到 eMMC ，下一次开发板重新启动，环境变量还会是我们修改后的值。</p>
              </div>
            </details>

<h1 id="四、内存操作"><a href="#四、内存操作" class="headerlink" title="四、内存操作"></a><font size=3>四、内存操作</font></h1><p>内存操作命令就是用于直接对 DRAM 进行读写操作的，常用的内存操作命令有 md、 nm、mm、 mw、 cp 和 cmp。  </p>
<h2 id="1-md"><a href="#1-md" class="headerlink" title="1. md"></a><font size=3>1. md</font></h2><h3 id="1-1-使用格式-2"><a href="#1-1-使用格式-2" class="headerlink" title="1.1 使用格式"></a><font size=3>1.1 使用格式</font></h3><p> md 命令用于显示内存值，格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">md[.b, .w, .l] address [# of objects]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>[.b .w .l] ：对应  byte 、 word 和  long ，也就是分别以  1 个字节 、  2 个字节、  4 个字节来显示内存值。</li>
<li>address ：要查看的内存起始地址。</li>
<li>[# of objects] ：表示要查看的数据长度，这个数据长度单位不是字节，而是跟我们所选择的显示格式有关。比如我们设置要查看的内存长度 为 20 (十六进制为  0x14 )，如果显示格式为  .b  的话那就表示 20 个字节；如果显示格式为 .w 的话就表示  20 个  word ，也就是  20*2&#x3D;40 个字节；如果显示格式为 .l 的话就表示  20 个  long ，也就是 20*4&#x3D;80 个字节。</li>
</ul>
<p><strong>【注意】</strong> </p>
<p>（1）uboot 命令中的<strong>数字都是十六进制的，不是十进制的</strong>！命令里面的数字都是十六进制的，所以可以不用写 0x 前缀，十进制的  20 其十六进制为  0x14 ，所以命令  md 后面的个数应该是 14 ，如果写成 20 的话就表示查看 32 (十六进制为 0x20 )个字节的数据。</p>
<p>（2）md与[.b, .w, .l]之间没有空格，紧挨着写。</p>
<h3 id="1-2-使用实例-2"><a href="#1-2-使用实例-2" class="headerlink" title="1.2 使用实例"></a><font size=3>1.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们若想查看以 0x80000000 开始的 20 个字节的内存值，显示格式为 .b 的话，应该使用如下所示命令：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; md.b 80000000 14</span><br><span class="line">80000000: ff ff f7 ff f7 ff ff ff ff ff ff ff ff ff ff ff    ................</span><br><span class="line">80000010: ff ff ff ff                                        ....</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="1-3-b、w、l"><a href="#1-3-b、w、l" class="headerlink" title="1.3 b、w、l"></a><font size=3>1.3 b、w、l</font></h3><p>这三者是指定显示内存值的基本单位，我们可以实际看一下这三个参数的区别：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">=&gt; md.b 80000000 10 </span><br><span class="line">80000000: ff ff f7 ff f7 ff ff ff ff ff ff ff ff ff ff ff    ................</span><br><span class="line">=&gt; md.w 80000000 10</span><br><span class="line">80000000: ffff fff7 fff7 ffff ffff ffff ffff ffff    ................</span><br><span class="line">80000010: ffff ffff ffff ffff ffff ffff ffff ffff    ................</span><br><span class="line">=&gt; md.l 80000000 10</span><br><span class="line">80000000: fff7ffff fffffff7 ffffffff ffffffff    ................</span><br><span class="line">80000010: ffffffff ffffffff ffffffff ffffffff    ................</span><br><span class="line">80000020: fffffffd bfffffff ffffffff ffffffff    ................</span><br><span class="line">80000030: ffffffff ffffffff ffffffff ffffffff    ................</span><br></pre></td></tr></table></figure>

<p>上面这三个命令都是查看以 0x80000000 为起始地址的内存数据，第一个命令以 .b 格式显示，长度为 0x10，也就是 16 个字节；第二个命令以 .w 格式显示，长度为 0x10，也就是 16*2&#x3D;32 个字节；最后一个命令以 .l 格式显示，长度也是 0x10，也就是 16*4&#x3D;64 个字节。  </p>
<h2 id="2-nm"><a href="#2-nm" class="headerlink" title="2. nm"></a><font size=3>2. nm</font></h2><h3 id="2-1-使用格式-3"><a href="#2-1-使用格式-3" class="headerlink" title="2.1 使用格式"></a><font size=3>2.1 使用格式</font></h3><p> nm 命令用于修改指定地址的内存值，命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nm[.b, .w, .l] address</span><br></pre></td></tr></table></figure>

<p> nm 命令同样可以以  .b 、 .w 和  .l 来指定操作格式。需要注意的是，修改内存需要两步，而且需要退出内存修改，后边的实例会有体现。</p>
<p><strong>【注意】</strong></p>
<p>（1）nm与[.b, .w, .l]之间没有空格，紧挨着写。</p>
<p>（2）使用 q 退出内存的修改。</p>
<h3 id="2-2-使用实例-2"><a href="#2-2-使用实例-2" class="headerlink" title="2.2 使用实例"></a><font size=3>2.2 使用实例</font></h3><p>例如，我们现在要以 .l 格式修改 0x80000000  地址处数据为 12345678 ，我们输入以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">=&gt; nm.l 80000000 </span><br><span class="line">80000000: fff7ffff ?</span><br></pre></td></tr></table></figure>

<p>其中 80000000 表示现在要修改的内存地址，  fff7ffff 表示地址 40008000 现在的数据， ? 后面就可以输入要修改后的数据 0x12345678 ，输入完成以后按下回车：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; nm.l 80000000 </span><br><span class="line">80000000: fff7ffff ? 12345678</span><br><span class="line">80000000: 12345678 ?</span><br></pre></td></tr></table></figure>

<p>这样我们便修改了相应的数据，然后输入 q 再按下回车就可以退出了</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; nm.l 80000000 </span><br><span class="line">80000000: fff7ffff ? 12345678</span><br><span class="line">80000000: 12345678 ? q</span><br></pre></td></tr></table></figure>

<h2 id="3-mm"><a href="#3-mm" class="headerlink" title="3. mm"></a><font size=3>3. mm</font></h2><h3 id="3-1-使用格式-2"><a href="#3-1-使用格式-2" class="headerlink" title="3.1 使用格式"></a><font size=3>3.1 使用格式</font></h3><p> mm 命令也是修改指定地址内存值的，使用  mm 修改内存值的时候<strong>地址会自增</strong>，而使用命令 nm 的话地址不会自增。使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mm[.b, .w, .l] address</span><br></pre></td></tr></table></figure>

<p>使用方式与 nm 一致，只不过它的地址会自己增加，</p>
<p><strong>【注意】</strong></p>
<p>（1）mm与[.b, .w, .l]之间没有空格，紧挨着写。</p>
<h3 id="3-2-使用实例-2"><a href="#3-2-使用实例-2" class="headerlink" title="3.2 使用实例"></a><font size=3>3.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>此处，我们以以 .l 格式修改从地址 0x80000000 开始的连续 3 个内存块（3*4&#x3D;12个字节）的数据为 0x87654321 ：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mm.l 80000000</span><br><span class="line">80000000: 12345678 ? 87654321</span><br><span class="line">80000004: fffffff7 ? 87654321</span><br><span class="line">80000008: ffffffff ? 87654321</span><br><span class="line">8000000c: ffffffff ? q</span><br><span class="line">=&gt; md.l 80000000 4</span><br><span class="line">80000000: 87654321 87654321 87654321 ffffffff    !Ce.!Ce.!Ce.....</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="4-mw"><a href="#4-mw" class="headerlink" title="4. mw"></a><font size=3>4. mw</font></h2><h3 id="4-1-使用格式-1"><a href="#4-1-使用格式-1" class="headerlink" title="4.1 使用格式"></a><font size=3>4.1 使用格式</font></h3><p> mw 用于使用一个指定的数据填充一段内存，命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mw[.b, .w, .l] address value [count]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>[.b .w .l] ：对应  byte 、 word 和  long ，也就是分别以  1 个字节 、  2 个字节、  4 个字节填充指定的内存。</li>
<li>address ：要查看的内存起始地址。</li>
<li>value ：为要填充的数据。</li>
<li>count ：填充的长度。</li>
</ul>
<h3 id="4-2-使用实例-1"><a href="#4-2-使用实例-1" class="headerlink" title="4.2 使用实例"></a><font size=3>4.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们使用.l 格式将以 0x80000000 为起始地址的 0x10 个内存块(0x10 * 4&#x3D;64 字节)填充为 0x50505050，  </p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mw.l 80000000 50505050 10</span><br><span class="line">=&gt; md.l 80000000 10         </span><br><span class="line">80000000: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000010: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000020: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000030: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="5-cp"><a href="#5-cp" class="headerlink" title="5. cp"></a><font size=3>5. cp</font></h2><h3 id="5-1-使用格式-1"><a href="#5-1-使用格式-1" class="headerlink" title="5.1 使用格式"></a><font size=3>5.1 使用格式</font></h3><p> cp 是数据拷贝命令，用于将  DRAM 中的数据从一段内存拷贝到另一段内存中，或者把  Nor Flash 中的数据拷贝到  DRAM 中。命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp[.b, .w, .l] source target count</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>[.b .w .l] ：对应  byte 、 word 和  long ，也就是分别以  1 个字节 、  2 个字节、  4 个字节拷贝数据。</li>
<li>source ：源地址。</li>
<li>target ：目的地址。</li>
<li>count ：为拷贝的长度。</li>
</ul>
<h3 id="5-2-使用实例-1"><a href="#5-2-使用实例-1" class="headerlink" title="5.2 使用实例"></a><font size=3>5.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们使用 .l 格式将 0x80000000 处的地址拷贝到 0X80000100 处，长度为 0x10 个内存块(0x10 * 4&#x3D;64 个字节)，命令如下所示：  </p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">=&gt; md.l 80000000 10 </span><br><span class="line">80000000: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000010: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000020: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000030: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">=&gt; md.l 80000100 10</span><br><span class="line">80000100: ffffffff fbffffff ffffffff ffffffff    ................</span><br><span class="line">80000110: ffffffff ffffffff fffff7ff ffffffff    ................</span><br><span class="line">80000120: ffff7fff ffffffff ffffffff ffffffff    ................</span><br><span class="line">80000130: ffffffff fffbffff ffffffff ffffffff    ................</span><br><span class="line">=&gt; cp.l 80000000 80000100 10</span><br><span class="line">=&gt; md.l 80000100 10         </span><br><span class="line">80000100: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000110: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000120: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000130: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="6-cmp"><a href="#6-cmp" class="headerlink" title="6. cmp"></a><font size=3>6. cmp</font></h2><h3 id="6-1-使用格式"><a href="#6-1-使用格式" class="headerlink" title="6.1 使用格式"></a><font size=3>6.1 使用格式</font></h3><p> cmp 是比较命令，用于比较两段内存的数据是否相等，命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cmp[.b, .w, .l] addr1 addr2 count</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>[.b .w .l] ：对应  byte 、 word 和  long ，也就是对应 1 个字节 、  2 个字节、  4 个字节。</li>
<li>addr1 ：第一段内存首地址。</li>
<li>addr1 ：第二段内存首地址。</li>
<li>count ：为要比较的长度。</li>
</ul>
<h3 id="6-2-使用实例"><a href="#6-2-使用实例" class="headerlink" title="6.2 使用实例"></a><font size=3>6.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们使用 .l 格式来比较 0x80000000 和 0x80000100 这两个地址数据是否相等，比较长度为 0x10 个内存块(16 * 4&#x3D;64 个字节)  </p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">=&gt; md.l 80000000 10         </span><br><span class="line">80000000: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000010: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000020: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000030: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">=&gt; md.l 80000100 10</span><br><span class="line">80000100: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000110: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000120: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">80000130: 50505050 50505050 50505050 50505050    PPPPPPPPPPPPPPPP</span><br><span class="line">=&gt; cmp.l 80000000 80000100 10</span><br><span class="line">Total of 16 word(s) were the same</span><br><span class="line">=&gt; cmp.l 80000000 80000100 11</span><br><span class="line">word at 0x80000040 (0xfffff7ff) != word at 0x80000140 (0xdff7ffff)</span><br><span class="line">Total of 16 word(s) were the same</span><br><span class="line">=&gt; cmp.l 80000000 80000100 13</span><br><span class="line">word at 0x80000040 (0xfffff7ff) != word at 0x80000140 (0xdff7ffff)</span><br><span class="line">Total of 16 word(s) were the same</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h1 id="五、存储器访问"><a href="#五、存储器访问" class="headerlink" title="五、存储器访问"></a><font size=3>五、存储器访问</font></h1><p>uboot 支持 EMMC 和 SD 卡，因此也会提供 EMMC 和 SD 卡的操作命令。  关于存储器的访问主要是 mmc 命令，我们使用 help mmc 来查看它的帮助信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">=&gt; help mmc</span><br><span class="line">mmc - MMC sub system</span><br><span class="line"></span><br><span class="line">Usage:</span><br><span class="line">mmc info - display info of the current MMC device</span><br><span class="line">mmc read addr blk# cnt</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">后边的省略 ... ...</span></span><br></pre></td></tr></table></figure>

<p>需要注意的是不同版本的uboot对命令的支持也不尽相同，关于目前使用的uboot2016.03版本中关于mmc的命令总结如下：</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>mmc info</td>
<td>输出 MMC 设备信息</td>
</tr>
<tr>
<td>mmc read</td>
<td>读取 MMC 中的数据。</td>
</tr>
<tr>
<td>mmc wirte</td>
<td>向 MMC 设备写入数据。</td>
</tr>
<tr>
<td>mmc rescan</td>
<td>扫描 MMC 设备。</td>
</tr>
<tr>
<td>mmc part</td>
<td>列出 MMC 设备的分区。</td>
</tr>
<tr>
<td>mmc dev</td>
<td>切换 MMC 设备。</td>
</tr>
<tr>
<td>mmc list</td>
<td>列出当前有效的所有 MMC 设备。</td>
</tr>
<tr>
<td>mmc hwpartition</td>
<td>设置 MMC 设备的分区。</td>
</tr>
<tr>
<td>mmc bootbus……</td>
<td>设置指定 MMC 设备的 BOOT_BUS_WIDTH 域的值。</td>
</tr>
<tr>
<td>mmc bootpart……</td>
<td>设置指定 MMC 设备的 boot 和 RPMB 分区的大小。</td>
</tr>
<tr>
<td>mmc partconf……</td>
<td>设置指定 MMC 设备的 PARTITION_CONFG 域的值。</td>
</tr>
<tr>
<td>mmc rst</td>
<td>复位 MMC 设备</td>
</tr>
<tr>
<td>mmc setdsr</td>
<td>设置 DSR 寄存器的值。</td>
</tr>
</tbody></table>
<h2 id="1-mmc-info"><a href="#1-mmc-info" class="headerlink" title="1. mmc info"></a><font size=3>1. mmc info</font></h2><h3 id="1-1-使用格式-3"><a href="#1-1-使用格式-3" class="headerlink" title="1.1 使用格式"></a><font size=3>1.1 使用格式</font></h3><p> 该命令用于查看当前设备的 mmc 信息，直接输入命令即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc info</span><br></pre></td></tr></table></figure>

<p>还有一个与 mmc info 命令相同功能的命令： mmcinfo，mmc和info之间没有空格。   </p>
<h3 id="1-2-使用实例-3"><a href="#1-2-使用实例-3" class="headerlink" title="1.2 使用实例"></a><font size=3>1.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mmc info</span><br><span class="line">Device: FSL_SDHC</span><br><span class="line">Manufacturer ID: 3</span><br><span class="line">OEM: 5344</span><br><span class="line">Name: SU04G </span><br><span class="line">Tran Speed: 50000000</span><br><span class="line">Rd Block Len: 512</span><br><span class="line">SD version 3.0</span><br><span class="line">High Capacity: Yes</span><br><span class="line">Capacity: 3.7 GiB</span><br><span class="line">Bus Width: 4-bit</span><br><span class="line">Erase Group Size: 512 Bytes</span><br></pre></td></tr></table></figure><p>这里我们采用的是从SD卡启动，所以默认的设备是SD卡，所以这里显示的是SD卡的相关信息。</p>
              </div>
            </details>

<h2 id="2-mmc-rescan"><a href="#2-mmc-rescan" class="headerlink" title="2. mmc rescan"></a><font size=3>2. mmc rescan</font></h2><p> mmc rescan 命令用于扫描当前开发板上所有的  MMC 设备，包括  EMMC 和  SD 卡，直接输入 mmc rescan 即可。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc rescan</span><br></pre></td></tr></table></figure>

<h2 id="3-mmc-list"><a href="#3-mmc-list" class="headerlink" title="3. mmc list"></a><font size=3>3. mmc list</font></h2><h3 id="3-1-使用格式-3"><a href="#3-1-使用格式-3" class="headerlink" title="3.1 使用格式"></a><font size=3>3.1 使用格式</font></h3><p> mmc list 命令用于来查看当前开发板一共有几个 MMC 设备，直接输入 mmc list 即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc list</span><br></pre></td></tr></table></figure>

<h3 id="3-2-使用实例-3"><a href="#3-2-使用实例-3" class="headerlink" title="3.2 使用实例"></a><font size=3>3.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mmc list</span><br><span class="line">FSL_SDHC: 0 (SD)</span><br><span class="line">FSL_SDHC: 1</span><br></pre></td></tr></table></figure><p>可以看出当前开发板有两个 MMC 设备： FSL_SDHC:0 和 FSL_SDHC:1 (eMMC)，这是因为现在用的是 EMMC 版本的核心板，加上 SD 卡一共有两个 MMC 设备， FSL_SDHC:0 是 SD卡， FSL_SDHC:1是 EMMC。由于我们启动方式设置的是从SD卡启动，所以默认会将 SD 卡设置为当前 MMC 设备，这就是为什么输入“mmc info”查询到的是 SD卡 设备信息，而不是 EMMC 。要想查看 EMMC 信息，就要使<br>用命令“mmc dev”来将 EMMC 设置为当前的 MMC 设备。  </p>
              </div>
            </details>

<h2 id="4-mmc-dev"><a href="#4-mmc-dev" class="headerlink" title="4. mmc dev"></a><font size=3>4. mmc dev</font></h2><h3 id="4-1-使用格式-2"><a href="#4-1-使用格式-2" class="headerlink" title="4.1 使用格式"></a><font size=3>4.1 使用格式</font></h3><p> mmc dev 命令用于切换当前 MMC 设备，一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc dev [dev] [part]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>dev ：设置要切换的  MMC 设备号。</li>
<li>part ：分区号，如果不写分区号的话默认为分区  0 。</li>
</ul>
<h3 id="4-2-使用实例-2"><a href="#4-2-使用实例-2" class="headerlink" title="4.2 使用实例"></a><font size=3>4.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mmc list</span><br><span class="line">FSL_SDHC: 0 (SD)</span><br><span class="line">FSL_SDHC: 1</span><br><span class="line"></span><br><span class="line">=&gt; mmc info</span><br><span class="line">Device: FSL_SDHC</span><br><span class="line">Manufacturer ID: 3</span><br><span class="line">OEM: 5344</span><br><span class="line">Name: SU04G </span><br><span class="line">Tran Speed: 50000000</span><br><span class="line">Rd Block Len: 512</span><br><span class="line">SD version 3.0</span><br><span class="line">High Capacity: Yes</span><br><span class="line">Capacity: 3.7 GiB</span><br><span class="line">Bus Width: 4-bit</span><br><span class="line">Erase Group Size: 512 Bytes</span><br><span class="line"></span><br><span class="line">=&gt; mmc dev 1</span><br><span class="line">switch to partitions #0, OK</span><br><span class="line">mmc1(part 0) is current device</span><br><span class="line"></span><br><span class="line">=&gt; mmc list</span><br><span class="line">FSL_SDHC: 0 (SD)</span><br><span class="line">FSL_SDHC: 1 (eMMC)</span><br><span class="line"></span><br><span class="line">=&gt; mmc info</span><br><span class="line">Device: FSL_SDHC</span><br><span class="line">Manufacturer ID: 15</span><br><span class="line">OEM: 100</span><br><span class="line">Name: 8GTF4 </span><br><span class="line">Tran Speed: 52000000</span><br><span class="line">Rd Block Len: 512</span><br><span class="line">MMC version 4.0</span><br><span class="line">High Capacity: Yes</span><br><span class="line">Capacity: 7.3 GiB</span><br><span class="line">Bus Width: 8-bit</span><br><span class="line">Erase Group Size: 512 KiB</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="5-mmc-part"><a href="#5-mmc-part" class="headerlink" title="5. mmc part"></a><font size=3>5. mmc part</font></h2><h3 id="5-1-使用格式-2"><a href="#5-1-使用格式-2" class="headerlink" title="5.1 使用格式"></a><font size=3>5.1 使用格式</font></h3><p>有时候  SD 卡或者  EMMC 会有多个分区，可以使用命令 mmc part 来查看其分区，直接输入命令即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc part</span><br></pre></td></tr></table></figure>

<h3 id="5-2-使用实例-2"><a href="#5-2-使用实例-2" class="headerlink" title="5.2 使用实例"></a><font size=3>5.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们来查看一下开发板中 emmc 的分区情况：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mmc dev 1</span><br><span class="line">switch to partitions #0, OK</span><br><span class="line">mmc1(part 0) is current device</span><br><span class="line">=&gt; mmc part</span><br><span class="line"></span><br><span class="line">Partition Map for MMC device 1  --   Partition Type: DOS</span><br><span class="line"></span><br><span class="line">Part    Start Sector    Num Sectors     UUID            Type</span><br><span class="line">  1     20480           262144          7f764a7b-01     0c</span><br><span class="line">  2     282624          14987264        7f764a7b-02     83</span><br></pre></td></tr></table></figure><p>此时 EMMC 有两个分区， 第一个分区起始扇区为 20480，长度为 262144 个扇区； 第二个分区起始扇区为 282624，长度为 14594048 个扇区。</p><p>如果 EMMC 里面烧写了 Linux 系统的话， EMMC 是有 3 个分区的，第 0 个分区存放 uboot，第 1 个分区存放 Linux 镜像文件和设备树，第 2 个分区存放根文件系统。但是在上边只有两个分区，那是因为第 0 个分区没有格式化，所以识别不出来，实际上第 0 个分区是存在的。</p><p>一个新的 SD 卡默认只有一个分区，那就是分区 0，所以前面讲解的 uboot 烧写到 SD 卡，其实就是将 u-boot.bin 烧写到了 SD 卡的分区 0 里面。  </p>
              </div>
            </details>

<h2 id="6-mmc-read"><a href="#6-mmc-read" class="headerlink" title="6. mmc read"></a><font size=3>6. mmc read</font></h2><h3 id="6-1-使用格式-1"><a href="#6-1-使用格式-1" class="headerlink" title="6.1 使用格式"></a><font size=3>6.1 使用格式</font></h3><p> mmc read 命令用于将 MMC 中指定扇区中的内容读取到内存中指定的地址，命令格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc read &lt;dev_num&gt; addr blk# cnt</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>dev_num ： mmc 的设备号，可以通过 mmc list 查询到，这个参数可以不写，不写的话默认为当前 mmc 设备。</li>
<li>addr ：数据读取到内存中的起始地址。 </li>
<li>blk# ：要读取的<strong>块</strong>起始地址 (十六进制 )，<strong>一个块是  512 字节</strong>，这里的块和扇区是一个意思，在  MMC 设备中我们通常说扇区。</li>
<li>cnt ：要读取的<strong>块</strong>数量 (十六进制 )。</li>
</ul>
<p><strong>【注意】</strong>一个块是 512 字节。</p>
<h3 id="6-2-使用实例-1"><a href="#6-2-使用实例-1" class="headerlink" title="6.2 使用实例"></a><font size=3>6.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们这里使用的mmc设备为SD卡，我们从 SD卡的第 1536（0x600）个块开始，读取 16（0x10）个块的数据到 DRAM 的0x80800000 地址处，命令如下：</p><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">=&gt; md.l <span class="number">80800000</span> <span class="number">20</span>        </span><br><span class="line"><span class="number">80800000</span>: <span class="number">6</span>c696146 <span class="number">20657275</span> <span class="number">6e616863</span> <span class="number">676e6967</span>    Failure changing</span><br><span class="line"><span class="number">80800010</span>: <span class="number">73756220</span> <span class="number">65707320</span> <span class="number">28206465</span> <span class="number">0</span>a296425     bus speed (%d).</span><br><span class="line"><span class="number">80800020</span>: <span class="number">6</span>c615600 <span class="number">63206469</span> <span class="number">20706968</span> <span class="number">72646461</span>    .Valid chip addr</span><br><span class="line"><span class="number">80800030</span>: <span class="number">65737365</span> <span class="number">20003</span>a73 <span class="number">58323025</span> <span class="number">72754300</span>    esses:. %<span class="number">02</span>X.Cur</span><br><span class="line"><span class="number">80800040</span>: <span class="number">746e6572</span> <span class="number">73756220</span> <span class="number">20736920</span> <span class="number">000</span>a6425    rent bus is %d..</span><br><span class="line"><span class="number">80800050</span>: <span class="number">61766e49</span> <span class="number">2064696</span>c <span class="number">20737562</span> <span class="number">000</span>a6425    Invalid bus %d..</span><br><span class="line"><span class="number">80800060</span>: <span class="number">74746553</span> <span class="number">20676e69</span> <span class="number">20737562</span> <span class="number">25206f</span>74    Setting bus to %</span><br><span class="line"><span class="number">80800070</span>: <span class="number">46000</span>a64 <span class="number">756</span>c6961 <span class="number">63206572</span> <span class="number">676e6168</span>    d..Failure chang</span><br><span class="line">=&gt; mmc dev <span class="number">0</span></span><br><span class="line"><span class="keyword">switch</span> to partitions #<span class="number">0</span>, OK</span><br><span class="line">mmc0 is current device</span><br><span class="line">=&gt; mmc read <span class="number">80800000</span> <span class="number">600</span> <span class="number">10</span></span><br><span class="line"></span><br><span class="line">MMC read: dev # <span class="number">0</span>, block # <span class="number">1536</span>, count <span class="number">16</span> ... <span class="number">16</span> blocks read: OK</span><br><span class="line">=&gt; md.l <span class="number">80800000</span> <span class="number">20</span>        </span><br><span class="line"><span class="number">80800000</span>: a288750f <span class="number">64756162</span> <span class="number">65746172</span> <span class="number">3531313</span>d    .u..baudrate=<span class="number">115</span></span><br><span class="line"><span class="number">80800010</span>: <span class="number">00303032</span> <span class="number">72616f</span>62 <span class="number">616e5</span>f64 <span class="number">453</span>d656d    <span class="number">200.b</span>oard_name=E</span><br><span class="line"><span class="number">80800020</span>: <span class="number">62004b</span>56 <span class="number">6472616f</span> <span class="number">7665725f</span> <span class="number">5834313</span>d    VK.board_rev=<span class="number">14</span>X</span><br><span class="line"><span class="number">80800030</span>: <span class="number">62003431</span> <span class="number">5f</span>746f6f <span class="number">3</span>d746466 <span class="number">00797274</span>    <span class="number">14.b</span>oot_fdt=try.</span><br><span class="line"><span class="number">80800040</span>: <span class="number">746f</span>6f62 <span class="number">73677261</span> <span class="number">6e6</span>f633d <span class="number">656</span>c6f73    bootargs=console</span><br><span class="line"><span class="number">80800050</span>: <span class="number">7974743</span>d <span class="number">3063786</span>d <span class="number">3531312</span>c <span class="number">20303032</span>    =ttymxc0,<span class="number">115200</span> </span><br><span class="line"><span class="number">80800060</span>: <span class="number">746f</span>6f72 <span class="number">65642f</span>3d <span class="number">666e2</span>f76 <span class="number">666e2073</span>    root=/dev/nfs nf</span><br><span class="line"><span class="number">80800070</span>: <span class="number">6f</span>6f7273 <span class="number">39313</span>d74 <span class="number">36312e32</span> <span class="number">30312e38</span>    sroot=<span class="number">192.168</span><span class="number">.10</span></span><br></pre></td></tr></table></figure><p>从这里我们可以看到，uboot的环境变量是保存在了SD卡中，并且存储起始地址就是1536*512&#x3D;786432。  </p>
              </div>
            </details>

<h2 id="7-mmc-write"><a href="#7-mmc-write" class="headerlink" title="7. mmc write"></a><font size=3>7. mmc write</font></h2><h3 id="7-1-使用格式"><a href="#7-1-使用格式" class="headerlink" title="7.1 使用格式"></a><font size=3>7.1 使用格式</font></h3><p> mmc write 命令用于将数据写到 MMC 设备里面。我们可以使用命令 mmc write命令来升级  uboot ，也就是在  uboot 中更新uboot 。这里会要用到 nfs 或者  tftp 命令，通过 nfs 或者 tftp 命令将新的  u-boot.bin 下载到开发板的 DRAM 中，然后再使用命令 mmc write 将其写入到 MMC 设备中。一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc write &lt;dev_num&gt; addr blk# cnt</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>dev_num ： mmc 的设备号，可以通过 mmc list 查询到，这个参数可以不写，不写的话默认为当前 mmc 设备。</li>
<li>addr ：数据将要写入到内存中的起始地址。 </li>
<li>blk# ：要写入的块起始地址 (十六进制 )，一个块是  512 字节，这里的块和扇区是一个意思，在  MMC 设备中我们通常说扇区。</li>
<li>cnt ：要写入的块数量 (十六进制 )。</li>
</ul>
<p><strong>【注意】</strong>千万不要写  SD 卡或者 EMMC 的前两个块 (扇区 )，里面保存着分区表。</p>
<h3 id="7-2-使用实例"><a href="#7-2-使用实例" class="headerlink" title="7.2 使用实例"></a><font size=3>7.2 使用实例</font></h3><p>我们可以使用命令 mmc write 来升级 uboot，也就是在 uboot 中更新 uboot。这里要用到 nfs 或者 tftp 命令，通过 nfs 或者 tftp 命令将新的 u-boot.bin 下载到开发板的 DRAM 中，然后再使用命令 mmc write 将其写入到 MMC设备中。  </p>
<h4 id="7-2-1-更新SD卡中的uboot"><a href="#7-2-1-更新SD卡中的uboot" class="headerlink" title="7.2.1 更新SD卡中的uboot"></a><font size=3>7.2.1 更新SD卡中的uboot</font></h4><ul>
<li>查看原来的uboot信息</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mmc dev 0</span><br><span class="line">switch to partitions #0, OK</span><br><span class="line">mmc0 is current device</span><br><span class="line">=&gt; version </span><br><span class="line"></span><br><span class="line">U-Boot 2016.03-g9e33bde-dirty (Sep 25 2022 - 21:24:46 +0800)</span><br><span class="line">arm-linux-gnueabihf-gcc (Linaro GCC 4.9-2017.01) 4.9.4</span><br><span class="line">GNU ld (Linaro_Binutils-2017.01) 2.24.0.20141017 Linaro 2014_11-3-git</span><br></pre></td></tr></table></figure>

<p>我们切换到SD卡设备，然后查看一下当前的uboot信息，可以看到目前的uboot编译时间为 Sep 25 2022 - 21:24:46。</p>
<ul>
<li>重新编译uboot，并生成load.imx文件</li>
</ul>
<p>重编编译uboot后，我们会得到一个 u-boot.bin 文件，这个文件不能直接使用，我们还需要通过烧写工具加上一些信息，得到一个 .imx 文件，这个可以修改一下源码，将 imxdownload.c 文件中的这句注释掉：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">system(cmdbuf);</span><br></pre></td></tr></table></figure>

<p>这样就不会真的烧写到设备节点啦，所以这个情况下，设备节点随便写就是了，然后我们就会得到一个 load.imx文件，然后我们将这个文件放到tftp目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/home/hk/3tftp/imx6ull/load.imx</span><br></pre></td></tr></table></figure>

<details class="folding-tag" blue><summary> 点击查看直接方式 </summary>
              <div class='content'>
              <p>其实，uboot源码中带有一个工具，我们编译好uboot后，会自动生成一个 u-boot.imx 文件，我们可以直接使用的。</p>
              </div>
            </details>

<ul>
<li>通过tftp下载uboot</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">=&gt; tftp 80800000 /imx6ull/load.imx</span><br><span class="line">FEC1 Waiting for PHY auto negotiation to complete... done</span><br><span class="line">Using FEC1 device</span><br><span class="line">TFTP from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/imx6ull/load.imx&#x27;.</span><br><span class="line">Load address: 0x80800000</span><br><span class="line">Loading: #############################</span><br><span class="line">         75.2 KiB/s</span><br><span class="line">done</span><br><span class="line">Bytes transferred = 421464 (66e58 hex)</span><br></pre></td></tr></table></figure>

<p>可以看出，load.imx 大小为 421464 字节， 421464&#x2F;512&#x3D;824，所以我们要向 SD 卡中写入824（0x338）个块（如果有小数的话就要加 1 个块  ）。</p>
<ul>
<li>写入uboot到SD卡中</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">=&gt; mmc dev 0 0</span><br><span class="line">switch to partitions #0, OK</span><br><span class="line">mmc0 is current device</span><br><span class="line"></span><br><span class="line">=&gt; mmc write 80800000 2 338</span><br><span class="line"></span><br><span class="line">MMC write: dev # 0, block # 2, count 824 ... 824 blocks written: OK</span><br></pre></td></tr></table></figure>

<ul>
<li>重启开发板，查看编译时间</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; version</span><br><span class="line"></span><br><span class="line">U-Boot 2016.03-g9e33bde-dirty (Oct 13 2022 - 17:11:27 +0800)</span><br><span class="line">arm-linux-gnueabihf-gcc (Linaro GCC 4.9-2017.01) 4.9.4</span><br><span class="line">GNU ld (Linaro_Binutils-2017.01) 2.24.0.20141017 Linaro 2014_11-3-git</span><br></pre></td></tr></table></figure>

<p>可以看到此时的uboot编译时间变成了 Oct 13 2022 - 17:11:27，这也就意味着我们完成了SD卡中uboot的更新。</p>
<h4 id="7-2-2-更新EMMC中uboot"><a href="#7-2-2-更新EMMC中uboot" class="headerlink" title="7.2.2 更新EMMC中uboot"></a><font size=3>7.2.2 更新EMMC中uboot</font></h4><p>其实跟更新SD卡中 uboot 过程类似，这里只写需要的命令（在开发板的终端执行）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mmc dev 1 0                      # 切换到 EMMC 分区 0</span><br><span class="line">tftp 80800000 /imx6ull/load.imx  # 下载 load.imx 到 DRAM</span><br><span class="line">mmc write 80800000 2 338         # 烧写 load.imx 到 EMMC 中</span><br><span class="line">mmc partconf 1 1 0 0             # 分区配置， EMMC 需要这一步</span><br></pre></td></tr></table></figure>

<h2 id="8-mmc-erase"><a href="#8-mmc-erase" class="headerlink" title="8. mmc erase"></a><font size=3>8. mmc erase</font></h2><p> mmc erase 命令用于擦除 MMC 设备的指定块，一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mmc erase blk# cnt</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>blk# ：要擦除的起始块。</li>
<li>cnt ：要擦除的数量。</li>
</ul>
<p><strong>【注意】</strong>一般不要用  mmc erase 来擦除  MMC 设备。</p>
<h1 id="六、网络操作"><a href="#六、网络操作" class="headerlink" title="六、网络操作"></a><font size=3>六、网络操作</font></h1><p>在 uboot 中，至少支持的外设就是串口和网口，因为我们需要通过这两个外设进行文件的传输，下边我们先来学习一下网络操作相关命令吧。这里需要注意I.MX6U-ALPHA 开发板有两个网口： ENET1 和 ENET2，一定要连接 ENET2，当然也可以修改uboot源码，使其改为 ENET1 ，默认没有修改的是使用的 ENET2。</p>
<h2 id="1-网络环境变量"><a href="#1-网络环境变量" class="headerlink" title="1. 网络环境变量"></a><font size=3>1. 网络环境变量</font></h2><p>要使用网络的话，还是需要先设置一下网络的相关环境变量。相关的环境变量如下：</p>
<table>
    <tr><td align="center">环境变量</td><td align="center">描述</td></tr>
    <tr><td align="left">ipaddr</td><td align="left">开发板 IP 地址，可以不设置，使用 dhcp 命令来从路由器获取 IP 地址。</td></tr>
    <tr><td align="left">ethaddr</td><td align="left">开发板的 MAC 地址，一定要设置。</td></tr>
    <tr><td align="left">gatewayip</td><td align="left">网关地址。</td></tr>
    <tr><td align="left">netmask</td><td align="left">子网掩码。</td></tr>
    <tr><td align="left">serverip</td><td align="left">服务器IP地址，也就是 Ubuntu主机 IP 地址，用于调试代码。</td></tr>
</table>

<p><strong>【注意】</strong></p>
<p>（1）开发板的 IP 一定要与 ubuntu 主机的 IP 处于网段，这样才能实现网络通信。</p>
<p>（2）如果在同一个网段内有多个开发板的话一定要保证每个开发板的 ethaddr 是不同的，否则通信会有问题。</p>
<p>我的一般设置如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">=&gt; setenv ipaddr 192.168.10.102</span><br><span class="line">=&gt; setenv ethaddr b8:ae:1d:01:00:00</span><br><span class="line">=&gt; setenv gatewayip 192.168.10.1 </span><br><span class="line">=&gt; setenv netmask 255.255.255.0</span><br><span class="line">=&gt; setenv serverip 192.168.10.101</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">最后再保存一下环境变量到 mmc</span></span><br><span class="line">=&gt; saveenv</span><br><span class="line">Saving Environment to MMC...</span><br><span class="line">Writing to MMC(0)... done</span><br></pre></td></tr></table></figure>

<h2 id="2-ping"><a href="#2-ping" class="headerlink" title="2. ping"></a><font size=3>2. ping</font></h2><h3 id="2-1-使用格式-4"><a href="#2-1-使用格式-4" class="headerlink" title="2.1 使用格式"></a><font size=3>2.1 使用格式</font></h3><p>我们的开发板的网络能否使用，是否可以和服务器 ( Ubuntu 主机 )进行通信，可以通过 ping 命令验证，直接 ping 服务器的 IP 地址即可，一般格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ping ip_addr</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>ip_addr ：表示我们要测试是否可联通的的 ip 地址。</li>
</ul>
<p><strong>【注意】</strong></p>
<p>（1）只能在  uboot 中  ping 其他的机器，其他机器不能  ping uboot ，因为  uboot 没有对  ping 命令做处理，如果用其他的机器  ping uboot 的话会失败。</p>
<h3 id="2-2-使用实例-3"><a href="#2-2-使用实例-3" class="headerlink" title="2.2 使用实例"></a><font size=3>2.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>比如我的服务器 IP 地址为  192.168.10.100 ，那么命令格式如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ping 192.168.10.100</span><br></pre></td></tr></table></figure><p>如果连接成功的话，会有以下信息提示：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">=&gt; ping 192.168.10.100</span><br><span class="line">FEC1 Waiting for PHY auto negotiation to complete... done</span><br><span class="line">Using FEC1 device</span><br><span class="line">host 192.168.10.100 is alive</span><br></pre></td></tr></table></figure><p>如果连接不成功（服务器没开启或者说 IP 不在同一网段的话），可能会有以下提示：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; ping 192.168.10.102</span><br><span class="line">Using FEC1 device</span><br><span class="line"></span><br><span class="line">ARP Retry count exceeded; starting again</span><br><span class="line">ping failed; host 192.168.10.102 is not alive</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="3-dhcp"><a href="#3-dhcp" class="headerlink" title="3. dhcp"></a><font size=3>3. dhcp</font></h2><p> dhcp 用于从路由器获取 IP 地址，前提得开发板连接到路由器上的，如果开发板是和电脑直连的，那么 dhcp 命令就会失效。直接输入 dhcp 命令即可通过路由器获取到 IP 地址。</p>
<h2 id="4-tftp"><a href="#4-tftp" class="headerlink" title="4. tftp"></a><font size=3>4. tftp</font></h2><h3 id="4-1-使用格式-3"><a href="#4-1-使用格式-3" class="headerlink" title="4.1 使用格式"></a><font size=3>4.1 使用格式</font></h3><p> tftp 命令用于通过网络下载数据到指定的内存地址中， tftp 命令使用的是 TFTP 协议， ubuntu 主机作为 TFTP 服务器。因此需要在  ubuntu 上搭建 TFTP 服务器，之前的时候我们已经搭建并本地验证过了（Linux开发中的《LV10-01-TFTP和NFS》这篇笔记），在 uboot 中使用的格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tftpboot [loadAddress] [[hostIPaddr:]bootfilename]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>tftpboot ：命令的全称，但是其实我们输入一个 tftp 就足够了。</li>
<li>loadAddress ：是要下载的文件在内存（ DRAM ）中的存放地址。</li>
<li>hostIPaddr ：服务器的 IP 地址，实际就是 ubuntu 主机的 IP 地址，如果说前边我们设置了 serverip 环境变量的话，这里是可以省略的。</li>
<li>bootfilename ：是要从 ubuntu 中下载的文件这个文件是以服务器中 tftp 目录为根目录的。</li>
</ul>
<h3 id="4-2-使用实例-3"><a href="#4-2-使用实例-3" class="headerlink" title="4.2 使用实例"></a><font size=3>4.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>例如，我们前边设置的 tftp 目录为 &#x2F;home&#x2F;hk&#x2F;3tftp ，然后我们需要下载这个文件：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/home/hk/3tftp/imx6ull/lcd.bin</span><br></pre></td></tr></table></figure><p>这个时候我们使用的命令如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; tftp 80000000 /imx6ull/lcd.bin</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">或者</span></span><br><span class="line">=&gt; tftp 80000000 192.168.10.101:/imx6ull/lcd.bin</span><br></pre></td></tr></table></figure><p>按下 enter 按键之后，我们会得到以下提示：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">=&gt; tftp 80000000 /imx6ull/lcd.bin</span><br><span class="line">Using FEC1 device</span><br><span class="line">TFTP from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/imx6ull/lcd.bin&#x27;.</span><br><span class="line">Load address: 0x80000000</span><br><span class="line">Loading: ###</span><br><span class="line">         731.4 KiB/s</span><br><span class="line">done</span><br><span class="line">Bytes transferred = 35953 (8c71 hex)</span><br><span class="line">=&gt; tftp 80000000 192.168.10.101:/imx6ull/lcd.bin</span><br><span class="line">Using FEC1 device</span><br><span class="line">TFTP from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/imx6ull/lcd.bin&#x27;.</span><br><span class="line">Load address: 0x80000000</span><br><span class="line">Loading: ###</span><br><span class="line">         899.4 KiB/s</span><br><span class="line">done</span><br><span class="line">Bytes transferred = 35953 (8c71 hex)</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="5-nfs"><a href="#5-nfs" class="headerlink" title="5. nfs"></a><font size=3>5. nfs</font></h2><h3 id="5-1-命令简介"><a href="#5-1-命令简介" class="headerlink" title="5.1 命令简介"></a><font size=3>5.1 命令简介</font></h3><p>nfs(Network File System)网络文件系统，通过 nfs 可以在计算机之间通过网络来分享资源，比如我们将 linux 镜像和设备树文件放到 ubuntu 中，然后在 uboot 中使用 nfs 命令将 ubuntu 中的 linux 镜像和设备树下载到开发板的 DRAM 中。这样做的目的是为了方便调试 linux 镜像和设备树，也就是网络调试，通过网络调试是 Linux 开发中最常用的调试方法。</p>
<p>原因是嵌入式 linux开发不像单片机开发，可以直接通过 JLINK 或 STLink 等仿真器将代码直接烧写到单片机内部的 flash 中，嵌入式 Linux 通常是烧写到 EMMC、 NAND Flash、 SPI Flash 等外置 flash 中，但是嵌入式 Linux 开发也没有 MDK， IAR 这样的 IDE，更没有烧写算法，因此不可能通过点击一个“download”按钮就将固件烧写到外部 flash 中。虽然半导体厂商一般都会提供一个烧写固件的软件，但是这个软件使用起来比较复杂，这个烧写软件一般用于量产的。其远没有 MDK、 IAR的一键下载方便，在 Linux 内核调试阶段，如果用这个烧写软件的话将会非常浪费时间，而这个时候网络调试的优势就显现出来了，可以通过网络将编译好的 linux 镜像和设备树文件下载到 DRAM 中，然后就可以直接运行。  </p>
<h3 id="5-2-使用格式"><a href="#5-2-使用格式" class="headerlink" title="5.2 使用格式"></a><font size=3>5.2 使用格式</font></h3><p>首先是需要搭建nfs的环境，可以看这篇笔记：Linux开发中的《LV10-01-TFTP和NFS》。一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nfs [loadAddress] [[hostIPaddr:]bootfilename]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>nfs ：命令的全称。</li>
<li>loadAddress ：是要下载的文件在内存（ DRAM ）中的保存的地址。</li>
<li>hostIPaddr ：服务器的 IP 地址，实际就是 ubuntu 主机的 IP 地址，如果说前边我们设置了 serverip 环境变量的话，这里是可以省略的。</li>
<li>bootfilename ：是要从 ubuntu 中下载的文件，这里似乎是需要一个<strong>相对于ubuntu根目录的绝对路径</strong>才可以。</li>
</ul>
<h3 id="5-3-使用实例"><a href="#5-3-使用实例" class="headerlink" title="5.3 使用实例"></a><font size=3>5.3 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们在ubuntu的nfs目录中有这样一个文件：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/home/hk/4nfs/imx_rootfs/linuxrc</span><br></pre></td></tr></table></figure><p>我们现在通过nfs命令将这个文件下载到开发板内存的 0x80000000，可使用如下命令：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">=&gt; nfs 80000000 192.168.10.101:/home/hk/4nfs/imx_rootfs/linuxrc </span><br><span class="line">Using FEC1 device</span><br><span class="line">File transfer via NFS from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/home/hk/4nfs/imx_rootfs/linuxrc&#x27;.</span><br><span class="line">Load address: 0x80000000</span><br><span class="line">Loading: #################################################################</span><br><span class="line">         #################################################################</span><br><span class="line">         ########</span><br><span class="line">done</span><br><span class="line">Bytes transferred = 703904 (abda0 hex)</span><br><span class="line">=&gt; nfs 80000000 /home/hk/4nfs/imx_rootfs/linuxrc               </span><br><span class="line">Using FEC1 device</span><br><span class="line">File transfer via NFS from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/home/hk/4nfs/imx_rootfs/linuxrc&#x27;.</span><br><span class="line">Load address: 0x80000000</span><br><span class="line">Loading: #################################################################</span><br><span class="line">         #################################################################</span><br><span class="line">         ########</span><br><span class="line">done</span><br><span class="line">Bytes transferred = 703904 (abda0 hex)</span><br></pre></td></tr></table></figure><p>这里关于后边文件路径问题，我尝试了使用 nfs 目录作为根目录，这样就无法找到相应的文件了，会有如下情况：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">=&gt; nfs 80000000 192.168.10.101:/imx_rootfs/linuxrc</span><br><span class="line">FEC1 Waiting for PHY auto negotiation to complete... done</span><br><span class="line">Using FEC1 device</span><br><span class="line">File transfer via NFS from server 192.168.10.101; our IP address is 192.168.10.102</span><br><span class="line">Filename &#x27;/imx_rootfs/linuxrc&#x27;.</span><br><span class="line">Load address: 0x80000000</span><br><span class="line">Loading: *** ERROR: Cannot mount</span><br><span class="line">T T </span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h1 id="七、文件系统操作"><a href="#七、文件系统操作" class="headerlink" title="七、文件系统操作"></a><font size=3>七、文件系统操作</font></h1><p>有时候需要在 uboot 中对 SD 卡或者 EMMC 中存储的文件进行操作，这时候就要用到文件操作命令。</p>
<h2 id="1-FAT-格式文件系统"><a href="#1-FAT-格式文件系统" class="headerlink" title="1. FAT 格式文件系统"></a><font size=3>1. FAT 格式文件系统</font></h2><h3 id="1-1-fatinfo"><a href="#1-1-fatinfo" class="headerlink" title="1.1 fatinfo"></a><font size=3>1.1 fatinfo</font></h3><h4 id="1-1-1-使用格式"><a href="#1-1-1-使用格式" class="headerlink" title="1.1.1 使用格式"></a><font size=3>1.1.1 使用格式</font></h4><p> fatinfo 命令用于查询指定 MMC 设备分区的文件系统信息，一般格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fatinfo &lt;interface&gt; [&lt;dev[:part]&gt;]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>interface ：表示接口，比如 mmc。</li>
<li>dev ：查询的设备号。</li>
<li>part ：要查询的分区。</li>
</ul>
<h4 id="1-1-2-使用实例"><a href="#1-1-2-使用实例" class="headerlink" title="1.1.2 使用实例"></a><font size=3>1.1.2 使用实例</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们要查询 EMMC 分区 1 的文件系统信息，命令如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">=&gt; fatinfo mmc 1:1</span><br><span class="line">Interface:  MMC</span><br><span class="line">  Device 1: Vendor: Man 000015 Snr c0fffe2a Rev: 0.6 Prod: 8GTF4R</span><br><span class="line">            Type: Removable Hard Disk</span><br><span class="line">            Capacity: 7456.0 MB = 7.2 GB (15269888 x 512)</span><br><span class="line">Filesystem: FAT32 &quot;NO NAME    &quot;</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="1-2-fatls"><a href="#1-2-fatls" class="headerlink" title="1.2 fatls"></a><font size=3>1.2 fatls</font></h3><h4 id="1-2-1-使用格式"><a href="#1-2-1-使用格式" class="headerlink" title="1.2.1 使用格式"></a><font size=3>1.2.1 使用格式</font></h4><p> fatls 命令用于查询 FAT 格式设备的目录和文件信息，一般格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fatls &lt;interface&gt; [&lt;dev[:part]&gt;] [directory]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>interface ：表示接口，比如 mmc 。</li>
<li>dev ：查询的设备号。</li>
<li>part ：要查询的分区。</li>
<li>directory ：是要查询的目录。</li>
</ul>
<h4 id="1-2-2-使用实例"><a href="#1-2-2-使用实例" class="headerlink" title="1.2.2 使用实例"></a><font size=3>1.2.2 使用实例</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们要查询 EMMC 分区 1 的所有目录和文件（正点原子开发板出厂的时候EMMC中有相应的一些文件），命令如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">=&gt; fatls mmc 1:1</span><br><span class="line">  6785360   zimage </span><br><span class="line">    39323   imx6ull-14x14-emmc-4.3-480x272-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-4.3-800x480-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-7-800x480-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-7-1024x600-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-10.1-1280x800-c.dtb </span><br><span class="line">    40159   imx6ull-14x14-emmc-hdmi.dtb </span><br><span class="line">    40067   imx6ull-14x14-emmc-vga.dtb </span><br><span class="line"></span><br><span class="line">8 file(s), 0 dir(s)</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="1-3-fstype"><a href="#1-3-fstype" class="headerlink" title="1.3 fstype   "></a><font size=3>1.3 fstype   </font></h3><h4 id="1-3-1-使用格式"><a href="#1-3-1-使用格式" class="headerlink" title="1.3.1 使用格式"></a><font size=3>1.3.1 使用格式</font></h4><p> fstype 命令用于查看 MMC 设备某个分区的文件系统格式  ，一般格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fstype &lt;interface&gt; &lt;dev&gt;:&lt;part&gt;</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>interface ：表示接口，比如 mmc 。</li>
<li>dev ：查询的设备号。</li>
<li>part ：要查询的分区。</li>
</ul>
<h4 id="1-3-2-使用实例"><a href="#1-3-2-使用实例" class="headerlink" title="1.3.2 使用实例"></a><font size=3>1.3.2 使用实例</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>在正点原子 EMMC 核心板上的 EMMC 在出厂的时候默认有 3 个分区，我们来查看一下这三个分区的文件系统格式  ，命令如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">=&gt; fstype mmc 1:0</span><br><span class="line">Failed to mount ext2 filesystem...</span><br><span class="line">** Unrecognized filesystem type **</span><br><span class="line">=&gt; fstype mmc 1:1</span><br><span class="line">fat</span><br><span class="line">=&gt; fstype mmc 1:2</span><br><span class="line">ext4</span><br></pre></td></tr></table></figure><ul><li><p>分区 0 格式未知，因为分区 0 存放的 uboot，并且分区 0 没有格式化，所以文件系统格式未知。</p></li><li><p>分区 1 的格式为 fat，分区 1 用于存放 linux 镜像和设备树。</p></li><li><p>分区 2 的格式为 ext4，用于存放 Linux 的根文件系统(rootfs)。</p></li></ul>
              </div>
            </details>

<h3 id="1-4-fatload"><a href="#1-4-fatload" class="headerlink" title="1.4 fatload"></a><font size=3>1.4 fatload</font></h3><h4 id="1-4-1-使用格式"><a href="#1-4-1-使用格式" class="headerlink" title="1.4.1 使用格式"></a><font size=3>1.4.1 使用格式</font></h4><p> fatload 命令用于将指定的文件读取到内存中，命令格式如下：，格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fatload &lt;interface&gt; [&lt;dev[:part]&gt;] &lt;addr&gt; &lt;filename&gt; [bytes [pos]]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>interface ：表示接口，比如 mmc 。</li>
<li>dev ：设备号。</li>
<li>part ：分区。</li>
<li>addr ：要保存到内存中的起始地址。</li>
<li>filename ：要读取的文件名字。 </li>
<li>bytes ：表示读取多少字节的数据，如果 bytes 为 0 或者省略的话表示读取整个文件。</li>
<li>pos ：是要读的文件相对于文件首地址的偏移，如果为 0 或者省略的话表示从文件首地址开始读取。</li>
</ul>
<h4 id="1-4-2-使用实例"><a href="#1-4-2-使用实例" class="headerlink" title="1.4.2 使用实例"></a><font size=3>1.4.2 使用实例</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>我们将 EMMC 分区 1 中的 zImage 文件读取到 DRAM 中的0x80800000 地址处，命令如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">=&gt; fatls mmc 1:1 </span><br><span class="line">  6785360   zimage </span><br><span class="line">    39323   imx6ull-14x14-emmc-4.3-480x272-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-4.3-800x480-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-7-800x480-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-7-1024x600-c.dtb </span><br><span class="line">    39323   imx6ull-14x14-emmc-10.1-1280x800-c.dtb </span><br><span class="line">    40159   imx6ull-14x14-emmc-hdmi.dtb </span><br><span class="line">    40067   imx6ull-14x14-emmc-vga.dtb </span><br><span class="line"></span><br><span class="line">8 file(s), 0 dir(s)</span><br><span class="line"></span><br><span class="line">=&gt; fatload mmc 1:1 80800000 zImage</span><br><span class="line">reading zImage</span><br><span class="line">6785360 bytes read in 223 ms (29 MiB/s)</span><br></pre></td></tr></table></figure><p>可以看出在 223ms 内读取了 6785360 个字节的数据，速度为 29MiB&#x2F;s，速度是非常快的，因为这是从 EMMC 里面读取的，而 EMMC 是 8 位的，速度就很快了。</p>
              </div>
            </details>

<h3 id="1-5-fatwrite"><a href="#1-5-fatwrite" class="headerlink" title="1.5 fatwrite  "></a><font size=3>1.5 fatwrite  </font></h3><h4 id="1-5-1-使用格式"><a href="#1-5-1-使用格式" class="headerlink" title="1.5.1 使用格式"></a><font size=3>1.5.1 使用格式</font></h4><p> fatwrite  命令用于将 DRAM 中的数据写入到 MMC 设备中，命令格式如下：，格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fatwrite &lt;interface&gt; &lt;dev[:part]&gt; &lt;addr&gt; &lt;filename&gt; &lt;bytes&gt;</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>interface ：表示接口，比如 mmc 。</li>
<li>dev ：设备号。</li>
<li>part ：分区。</li>
<li>addr ：要保存到内存中的起始地址。</li>
<li>filename ：要写入的文件名字。 </li>
<li>bytes ：表示读取多少字节的数据。</li>
</ul>
<p><strong>【注意】</strong>uboot 默认没有使能 fatwrite 命令，需要修改板子配置头文件，例如，mx6ullevk.h、mx6ull_alientek_emmc.h 等等，板子不同，其配置头文件也不同。找到所用的开发板对应的配置头文件然后添加如下一行宏定义来使能 fatwrite 命令：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_FAT_WRITE <span class="comment">/* 使能 fatwrite 命令 */</span></span></span><br></pre></td></tr></table></figure>

<h4 id="1-5-2-使用实例"><a href="#1-5-2-使用实例" class="headerlink" title="1.5.2 使用实例"></a><font size=3>1.5.2 使用实例</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>这里没有实际的去测试，使用的命令格式如下：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">tftp 80800000 zImage</span><br><span class="line">fatwrite mmc 1:1 80800000 zImage 6788f8</span><br></pre></td></tr></table></figure><p>zImage 大小为 6785272(0X6788f8)个字节(注意，由于开发板系统在不断的更新中，因此zImage 大小不是固定的，一切以实际大小为准)  </p>
              </div>
            </details>



<h2 id="2-EXT-格式文件系统"><a href="#2-EXT-格式文件系统" class="headerlink" title="2. EXT 格式文件系统"></a><font size=3>2. EXT 格式文件系统</font></h2><p>uboot 有 ext2 和 ext4 这两种格式的文件系统的操作命令，常用的就四个命令，分别为：ext2load、 ext2ls、 ext4load、 ext4ls 和ext4write。这些命令的含义和使用与 fatload、 fatls 和 fatwrite一样，只是 ext2 和 ext4 都是针对 ext 文件系统的。  </p>
<h1 id="八、boot-操作"><a href="#八、boot-操作" class="headerlink" title="八、boot 操作"></a><font size=3>八、boot 操作</font></h1><h2 id="1-两个环境变量"><a href="#1-两个环境变量" class="headerlink" title="1.两个环境变量"></a><font size=3>1.两个环境变量</font></h2><h3 id="1-1-boodcmd"><a href="#1-1-boodcmd" class="headerlink" title="1.1 boodcmd "></a><font size=3>1.1 boodcmd </font></h3><p> bootcmd 环境变量中保存着 uboot 的默认命令，该环境变量其实也叫做自启动环境变量。在我们重启开发板的时候，会有这么一个提示信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Hit any key to stop autoboot : 3</span><br></pre></td></tr></table></figure>

<p>这里就是 uboot 倒计时，这里的这个时间由环境变量 bootdelay 控制，当倒计时结束之前按下任意按键，就会进入 uboot 的一个命令行的模式，着大盖就类似于我们重装 windows 系统时的 BIOS 系统一样。</p>
<p>当我们在倒计时期间没有按下任何按键的话，<strong>倒计时结束以后就会执行 bootcmd 中的命令</strong>。这些命令一般用来启动 linu 内核，比如读取 EMMC 或者 NAND Flash 中的 linux 内核镜像文件和设备树文件到 DRAM 中，然后启动 linux 内核。可以在  uboot  启动以后进入命令行设置  bootcmd  环境变量的值。如果  EMMC  或者  NAND  中没有保存  bootcmd  的值，那么  uboot  就会使用默认的值，板子第一次运行  uboot  的时候都会使用默认值来设置  bootcmd  环境变量。</p>
<p><strong>【注意】</strong>该环境变量中可以有多条命令，多条命令之间用 <code>\; </code>分隔开，修改完后我们需要将环境变量进行保存，否则下次重启，我们设置的环境变量就会失效。</p>
<p><strong>【设置实例】</strong></p>
<p>另外，我们可以通过 run 命令来运行这个环境变量中的命令。例如，</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">=&gt; setenv bootcmd &#x27;tftp 80800000 /imx6ull/zImage\;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb\;bootz 80800000 - 83000000&#x27;</span><br><span class="line">=&gt; printenv bootcmd</span><br><span class="line">bootcmd=tftp 80800000 /imx6ull/zImage;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb;bootz 80800000 - 83000000</span><br><span class="line">=&gt; saveenv    </span><br><span class="line">Saving Environment to MMC...</span><br><span class="line">Writing to MMC(0)... done</span><br><span class="line">=&gt; run bootcmd</span><br></pre></td></tr></table></figure>

<h3 id="1-2-bootargs"><a href="#1-2-bootargs" class="headerlink" title="1.2 bootargs "></a><font size=3>1.2 bootargs </font></h3><p> bootargs  保存着  uboot  传递给  Linux  内核的参数，也被叫做自启动参数， uboot 不需要使用。在 Linux 内核源码里面有相应的文档讲解如何设置，文档为 Documentation&#x2F;filesystems&#x2F;nfs&#x2F;nfsroot.txt ，后边可以看一下，常见的格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">root=/dev/nfs nfsroot=[&lt;server-ip&gt;:]&lt;root-dir&gt;[,&lt;nfs-options&gt;] ip=&lt;client-ip&gt;:&lt;server-ip&gt;:&lt;gw-ip&gt;:&lt;netmask&gt;:&lt;hostname&gt;:&lt;device&gt;:&lt;autoconf&gt;:&lt;dns0-ip&gt;:&lt;dns1-ip&gt;</span><br></pre></td></tr></table></figure>

<details class="folding-tag" blue><summary> 点击查看参数说明 </summary>
              <div class='content'>
              <p><strong>【参数说明】</strong></p><ul><li>server-ip ：服务器 IP 地址，也就是存放根文件系统主机的 IP 地址，那就是 ubuntu 的 IP地址，比如我的 ubuntu 主机 IP 地址为 192.168.10.101。</li><li>root-dir ： 根文件系统的存放路径，比如我的就是 &#x2F;home&#x2F;hk&#x2F;4nfs。</li><li>nfs-options ： NFS 的其他可选选项，一般不设置。</li><li>client-ip ： 客户端 IP 地址，也就是开发板的 IP 地址， Linux 内核启动以后就会使用此 IP 地址来配置开发板。注意此地址一定要和 ubuntu 主机在同一个网段内，并且没有被其他的设备使用，在 ubuntu 中使用 ping 命令 ping 一下就知道要设置的 IP 地址有没有被使用，如果不能 ping 通就说明没有被使用，那么就可以设置为开发板的 IP 地址，比如我的开发板设置为192.168.10.102。</li><li>server-ip ： 服务器 IP 地址，就是ubuntu的IP地址，我的是192.168.10.101。</li><li>gw-ip ： 网关地址，我的是 192.168.10.1。</li><li>netmask ：子网掩码，我的是 255.255.255.0。</li><li>hostname ：客户机的名字，一般不设置，此值可以空着。</li><li>device ： 设备名，也就是网卡名，一般是 eth0， eth1….，正点原子的 I.MX6U-ALPHA 开发板的 ENET2 为 eth0， ENET1 为 eth1。如果电脑只有一个网卡，那么基本只能是 eth0，这里我们使用 ENET2，所以网卡名就是 eth0。</li><li>autoconf ： 自动配置，一般不使用，所以设置为 off。</li><li>dns0-ip ： DNS0 服务器 IP 地址，不使用。</li><li>dns1-ip ： DNS1 服务器 IP 地址，不使用。</li></ul><p>根据上边这个格式，我们的bootargs参数可以设置为：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">root=/dev/nfs nfsroot=192.168.10.101:/home/hk/4nfs/imx_rootfs,proto=tcp rw ip=192.168.10.102:192.168.10.101:192.168.10.1:255.255.255.0::eth0:off</span><br></pre></td></tr></table></figure><p>其中 proto&#x3D;tcp 表示使用 TCP 协议， rw 表示 nfs 挂载的根文件系统为可读可写 。</p>
              </div>
            </details>

<p><strong>【设置实例】</strong></p>
<p>最终我们设置的bootargs参数为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">=&gt; setenv bootargs &#x27;console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.10.101:/home/hk/4nfs/imx_rootfs,proto=tcp rw ip=192.168.10.102:192.168.10.101:192.168.10.1:255.255.255.0::eth0:off init=/linuxrc&#x27;</span><br><span class="line">=&gt; printenv bootargs                                                                         bootargs=console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.10.101:/home/hk/4nfs/imx_rootfs,proto=tcp rw ip=192.168.10.102:192.168.10.101:192.168.10.1:255.255.255.0::eth0:off</span><br><span class="line">=&gt; saveenv </span><br><span class="line">Saving Environment to MMC...</span><br><span class="line">Writing to MMC(0)... done</span><br></pre></td></tr></table></figure>

<p><strong>【命令说明】</strong></p>
<ul>
<li><p>console<br> console  用来设置  linux  终端(或者叫控制台)，也就是开发板安装好 linux 后，我们通过什么设备来和  Linux  进行交互，是串口还是  LCD  屏幕？如果是串口的话串口号是多少等。这里设置  console  为  ttySAC2 。 ttySAC2  后面有个 ,115200 ，这是设置串口的波特率， console&#x3D;ttySAC2,115200  综合起来就是设置  ttySAC2 作为  Linux  的终端，并且串口波特率设置为  115200 。</p>
</li>
<li><p>init</p>
</li>
</ul>
<p> init 用来指定 init 进程的程序路径，一般 init&#x3D;&#x2F;linuxrc , 或者 init&#x3D;&#x2F;etc&#x2F;preinit ， preinit 的内容一般是创建 console 、 null 设备节点，运行 init 程序，挂载一些文件系统等操作。我们可能以为 init&#x3D;&#x2F;linuxrc 是固定写法，其实不然， &#x2F;linuxrc 指的是 &#x2F; 目录下面的 linuxrc 脚本，一般指向 busybox 。</p>
<h2 id="2-bootz"><a href="#2-bootz" class="headerlink" title="2. bootz"></a><font size=3>2. bootz</font></h2><p>要启动 Linux，需要先将 Linux 镜像文件拷贝到 DRAM 中，如果使用到设备树的话也需要将设备树拷贝到 DRAM 中。可以从 EMMC 或者 NAND 等存储设备中将 Linux 镜像和设备树文件拷贝到 DRAM，也可以通过 nfs 或者 tftp 将 Linux 镜像文件和设备树文件下载到 DRAM 中。不管用那种方法，只要能将 Linux 镜像和设备树文件存到 DRAM 中就行，然后使用 bootz 命令来启动， bootz 命令用于启动 zImage 镜像文件  </p>
<h3 id="2-1-使用格式-5"><a href="#2-1-使用格式-5" class="headerlink" title="2.1 使用格式"></a><font size=3>2.1 使用格式</font></h3><p>一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bootz [addr [initrd[:size]] [fdt]]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>addr ：Linux 镜像文件在 DRAM 中的位置</li>
<li>initrd ：是 initrd 文件在DRAM 中的地址，如果不使用 initrd 的话使用‘ - ’代替即可。</li>
</ul>
<details class="folding-tag" blue><summary> 点击查看什么是 initrd </summary>
              <div class='content'>
              <p>Linux初始RAM磁盘（initrd）是在系统引导过程中挂载的一个临时根文件系统，用来支持两阶段的引导过程。initrd文件中包含了各种可执行程序和驱动程序，它们可以用来挂载实际的根文件系统，然后再将这个 initrd RAM磁盘卸载，并释放内存。在很多嵌入式Linux系统中，initrd 就是最终的根文件系统。</p>
              </div>
            </details>

<ul>
<li>fdt ：就是设备树文件在 DRAM 中的地址。</li>
</ul>
<h3 id="2-2-使用实例-4"><a href="#2-2-使用实例-4" class="headerlink" title="2.2 使用实例"></a><font size=3>2.2 使用实例</font></h3><h4 id="2-2-1-通过网络下载文件"><a href="#2-2-1-通过网络下载文件" class="headerlink" title="2.2.1 通过网络下载文件"></a><font size=3>2.2.1 通过网络下载文件</font></h4><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>首先我们在ubuntu中准备好所需文件：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">/home/hk/3tftp/imx6ull/zImage                # linux镜像文件</span><br><span class="line">/home/hk/3tftp/imx6ull/imx6ull-14x14-evk.dtb # 设备树文件      </span><br></pre></td></tr></table></figure><p>然后我们下载相应文件到开发板指定位置：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">=&gt; tftp 80800000 /imx6ull/zImage</span><br><span class="line">=&gt; tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb</span><br><span class="line">=&gt; bootz 80800000 - 83000000</span><br></pre></td></tr></table></figure><p>所有命令运行结果如下：</p><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-03-uboot%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4/img/image-20221013193827596.png" alt="image-20221013193827596" style="zoom: 50%;" />
              </div>
            </details>

<h4 id="2-2-2-通过EMMC启动"><a href="#2-2-2-通过EMMC启动" class="headerlink" title="2.2.2 通过EMMC启动"></a><font size=3>2.2.2 通过EMMC启动</font></h4><p>我们要从 EMMC 中启动 Linux 系统的话只需要使用命令 fatload 将 zImage 和 imx6ull-14x14-evk.dtb 从EMMC 的分区 1 中拷贝到 DRAM 中，然后使用命令 bootz 启动即可。</p>
<p>先使用命令 fatls 查看要下 EMMC 的分区 1 中有没有 Linux 镜像文件和设备树文件，如果没有的话就使用 fatwrite 命令将服务器tftp目录下的中的 zImage 和 imx6ull-14x14-evk.dtb 文件下载到内存，然后烧写到 EMMC 的分区 1 中。</p>
<p>EMMC中有相应的linux镜像文件和设备树文件后，我们就可以使用命令 fatload 将 zImage 和 imx6ull-14x14-evk.dtb文件拷贝到 DRAM 中，地址分别为 0x80800000 和 0x83000000，最后使用 bootz 启动。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">fatload mmc 1:1 80800000 zImage</span><br><span class="line">fatload mmc 1:1 83000000 imx6ull-14x14-evk.dtb</span><br><span class="line">bootz 80800000 - 83000000</span><br></pre></td></tr></table></figure>

<h2 id="3-bootm"><a href="#3-bootm" class="headerlink" title="3. bootm "></a><font size=3>3. bootm </font></h2><h3 id="3-1-使用格式-4"><a href="#3-1-使用格式-4" class="headerlink" title="3.1 使用格式"></a><font size=3>3.1 使用格式</font></h3><p> boom 命令也是用于启动linux系统的，不使用设备树时，一般使用格式如下：</p>
<div class="tabs" id="tabname1"><ul class="nav-tabs"><li class="tab active"><a href="#tabname1-1">格式一</a></li><li class="tab"><a href="#tabname1-2">格式二</a></li><li class="tab"><a href="#tabname1-3">格式三</a></li></ul><div class="tab-content"><div class="tab-pane active" id="tabname1-1"><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bootm [addr [arg ...]]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>addr 是 linux 镜像在 DRAM 中的首地址。</li>
<li>arg ：可以是一个 initrd 映像的地址，当引导一个需要设备树的 Linux 内核时，需要第三个参数，它是设备树的地址。要在不使用 initrd 镜像的情况下引导内核，我们需要使用 - 作为第二个参数。</li>
</ul></div><div class="tab-pane" id="tabname1-2"><p>其实有的资料中，该命令格式是这样的，我感觉更加详细一点：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bootm [addr [initrd[:size]] [fdt]]</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>addr ：是  Linux 镜像文件在 DRAM 中的位置，</li>
<li>initrd ：是  initrd 文件在 DRAM 中的地址，如果不使用  initrd 的话使用 - 代替即可 。</li>
<li>fdt ：就是设备树文件在  DRAM  中的地址。</li>
</ul>
<p><strong>【注意】</strong>若不使用相应的地址，对应的位置写 - 。</p></div><div class="tab-pane" id="tabname1-3"><p>或者直接这样写可能更清晰一点：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bootm kernel-addr ramdisk-addr dtb-addr</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>kernel-addr : 内核的下载地址 。</li>
<li>ramdisk-addr : 根文件系统的下载地址。</li>
<li>dtb-addr : 设备树的下载地址。</li>
</ul>
<p><strong>【注意】</strong>若不使用相应的地址，对应的位置写 - 。</p></div></div></div>

<h3 id="3-2-使用实例-4"><a href="#3-2-使用实例-4" class="headerlink" title="3.2 使用实例"></a><font size=3>3.2 使用实例</font></h3><p>与bootz一样。</p>
<h2 id="4-boot"><a href="#4-boot" class="headerlink" title="4. boot"></a><font size=3>4. boot</font></h2><h3 id="4-1-使用格式-4"><a href="#4-1-使用格式-4" class="headerlink" title="4.1 使用格式"></a><font size=3>4.1 使用格式</font></h3><p>boot 命令也是用来启动 Linux 系统的，只是 boot 会读取环境变量 bootcmd 来启动 Linux 系统，一般使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">boot</span><br></pre></td></tr></table></figure>

<p><strong>【注意】</strong>它启动linux的时候需要借助 bootcmd 环境变量。</p>
<h3 id="4-2-使用实例-4"><a href="#4-2-使用实例-4" class="headerlink" title="4.2 使用实例"></a><font size=3>4.2 使用实例</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <p>使用该命令的时候，我们需要输入的命令有：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">setenv bootcmd &#x27;tftp 80800000 /imx6ull/zImage\;tftp 83000000 /imx6ull/imx6ull-14x14-evk.dtb\;bootz 80800000 - 83000000&#x27;</span><br><span class="line">saveenv</span><br><span class="line">boot</span><br></pre></td></tr></table></figure>
              </div>
            </details>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/d56430c4.html">LV05-01-uboot-03-uboot相关命令</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年09月08日 - 19:22</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/d56430c4.html" title="LV05-01-uboot-03-uboot相关命令">https://sumumm.github.io/post/d56430c4.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/ALPHA-LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/" rel="tag"><i class="fa fa-tag"></i> (ALPHA)LV05-uboot与内核</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/e99b9cbc.html" rel="prev" title="LV05-01-uboot-04-uboot启动流程">
                  <i class="fa fa-angle-left"></i> LV05-01-uboot-04-uboot启动流程
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/3fdc035a.html" rel="next" title="LV05-01-uboot-02-uboot烧写">
                  LV05-01-uboot-02-uboot烧写 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
